简体   繁体   中英

How to make onclick event occur before onblur?

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')

尝试使用onmousedown而不是onclick

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM