最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to make onclick event occur before onblur? - Stack Overflow

programmeradmin8浏览0评论

I have 2 elements, an anchor with onclick = "..." and an input with onfocus = "..." The anchor is toggled by the input button, so when the button is in focus, the anchor is displayed and when it loses focus the anchor is hidden. Is there a way I can access the onclick event from the anchor without the onblur occurring first?

input(type="radio", name="sample", value=str(sample['id']),
     id="S"+str(sample['id']),onfocus = 'javascript:toggleVisibility("%stoggle");' 
     % sample['id'], onblur = 'toggleVisibility("%stoggle");' % sample['id'])

a("edit", id = "%stoggle" % str(sample['id']), style="display:none; float:right;
   padding-left:10px; text-decoration:none;", href='do something')

I have 2 elements, an anchor with onclick = "..." and an input with onfocus = "..." The anchor is toggled by the input button, so when the button is in focus, the anchor is displayed and when it loses focus the anchor is hidden. Is there a way I can access the onclick event from the anchor without the onblur occurring first?

input(type="radio", name="sample", value=str(sample['id']),
     id="S"+str(sample['id']),onfocus = 'javascript:toggleVisibility("%stoggle");' 
     % sample['id'], onblur = 'toggleVisibility("%stoggle");' % sample['id'])

a("edit", id = "%stoggle" % str(sample['id']), style="display:none; float:right;
   padding-left:10px; text-decoration:none;", href='do something')
Share Improve this question asked Jul 10, 2012 at 7:20 atfergusatfergus 3204 silver badges18 bronze badges 3
  • What do you mean by access? You want to fire onClick event or just get the function? And what do you need it for? There might me better solution... – Gatekeeper Commented Jul 10, 2012 at 7:25
  • I'd just like to be able to change the value displayed with the radio button. As it is now, the href address or code won't execute because the onblur happens before the href fires. Is there a quick way I can just get that to happen? – atfergus Commented Jul 10, 2012 at 7:28
  • Does it work now or still facing issues? – WolvDev Commented Jul 11, 2012 at 8:05
Add a ment  | 

1 Answer 1

Reset to default 5

Try to use the onmousedown instead of onclick.

发布评论

评论列表(0)

  1. 暂无评论