jquery assign onclick for li from a link

后端 未结 5 1001
长情又很酷
长情又很酷 2020-12-14 13:30

I have a list of items

5条回答
  •  庸人自扰
    2020-12-14 14:08

    Your best bet is probably to pick one specific element type -- perhaps the one with bigger dimensions -- and assign the click handler to those only. If the onclick is set to both the A tag and the LI (through whatever means), the call may happen twice, unless you specifically prevent such event bubbling in your named function.

    Is there a particular reason you want the same action to happen on both element types, instead of just one? (If it's something along the lines of "just a precaution," it's probably best to work out the issues instead of paving over them with more scripting.)

提交回复
热议问题