admin管理员组

文章数量:1026989

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.

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.

本文标签: javascriptHow to make onclick event occur before onblurStack Overflow