Skip to content Skip to sidebar Skip to footer

How To Get The Value Of Colspan

I have tried different jQuery approaches: var num = $(this).attr('colspan').text(); var num = $(this).attr('colspan').val(); var num = $(this).('td[colspan]').val(); var num = $(th

Solution 1:

Use prop to get the value set for the attribute/property, this will reflect any changes made to the property with JS after the page load:

$(this).prop("colSpan");

JS Fiddle:http://jsfiddle.net/9u8L2/1

Solution 2:

if this refers to the td element then

var span  = $(this).prop('colSpan')//orvar span  = $(this).attr('colspan')

Post a Comment for "How To Get The Value Of Colspan"