开发者

jquery binding events on selected tab

开发者 https://www.devze.com 2023-01-24 23:30 出处:网络
I have few tabs with same form inside of them, only difference is location of work in hidden element.

I have few tabs with same form inside of them, only difference is location of work in hidden element.

I'm loading my tabs with ajax a href="blah.htm"

I want to bind onClick to element in form, but problem is that since form is the same on all tabs jquery only operates on first instance, i.e. first tab.

Question is ..how can 开发者_StackOverflow社区i use jquery on selected tab instead on first tab?


You're not giving out a lot of details, but If I guess correctly the following will work for you

$('.myform input').click(function() {
//do something here
})

Ie. refer to your form by class instead of IDs or Names.

With this you get the added bonus of having per tab onClick handlers with zero efforts:

$('#tab1 .myform input')
0

精彩评论

暂无评论...
验证码 换一张
取 消