Reputation: 3858
I have an application which uses some Tabs. The functionality of these tabs is programmed with jquery (I dont know how to program jquery). So if I want to add a Tab I use this line:
<div class="tab">1</div>
I didnt program the function of that tab, but I need to add some other functions, so I am trying to use onclick()
on the DIV (as next) but does not work.
<div class="tab" onclick="prueba()">1</div>
In order to make it work, I need to use something like this:
<div class="tab"><span onclick="prueba()">1</span></div>
My problem is that the size of the DIV is bigger, so the onclick()
would only work by clicking exactly on the number, rather tahn any part of the div.
I already tryied to insert the DIV inside the Span (as next) but does not work.
<span onclick="prueba()"><div class="tab">1</div></span>
Does anyone know if this is happening because of jquery which is controling the functions on the tab??
Is there any way to use any element with onclick()
outside the DIV with the "tab" class??
Thanks a lot, and sorry for my english
function prueba() {
alert("HELLO");
}
Sorry not to put the jquery code, it is too long and I dont know exactly which part to show.
Upvotes: 1
Views: 7101
Reputation: 2134
from this "I have an application which uses some Tabs. The functionality of these tabs is programmed with jquery (I dont know how to program jquery). So if I want to add a Tab I use this line:"
it would sound as tho the jquery is looking for the "tab" class. I would suggest posting the jquery OR assigning the tab class to whatever element you wish to have trigger the action
ie:
<span class="tab" onclick="prueba()"><div >1</div></span>
would probably fire ( unless it wants a div.tab ) ? Lets guess!
Upvotes: 2
Reputation: 237110
Have you considered just using $('.tab').click(prueba)
or something along those lines? That's how you're generally meant to do this sort of thing with jQuery.
Upvotes: 3