I have a table of which I want to suppress the link clicks, because I need the links for other functionality.
The structure of the table is something like this:
<table>
<tr><th>Day</th><th>Event</th>
<tr class="DAY" id="DAY_0"><td>1-8-2013</td><td><a href="?tab=tabCalendar&dayEvent=DAY_0">Add Event</a></td></tr>
<tr class="DAY" id="DAY_1"><td>2-8-2013</td><td><a href="?tab=tabCalendar&dayEvent=DAY_1">Add Event</a></td></tr>
</table
my jquery code to try and block the from refreshing the page, and showing the id is this
<script>
$("a").click(
function(event) {
event.preventDefault();
alert('Picked: '+ event.target.id.slice(4) );
}
);
</script>
I have also tried the following
$(".DAY").click(function(){//to catch the class DAY.click()
and even
$("[id^=DAY]").click(function(){//to catch the id DAY*.click
however, none of these function did anything.
The versions I use are
jquery-1.9.1.js
jquery-ui-1.10.3.custom.js
Simplest approach:
<script>
$(".DAY").click(
function(event) {
event.preventDefault();
alert('Picked: '+ $(this).attr('id').slice(4));
}
);
</script>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With