1]'); The a...">

Choose td elemensts with colspan

How can I get all td elements with "colspan" greater than 1 in jQuery?

var nodes = $('td[colspan>1]'); 

The above code does not work.

+6
source share
3 answers

Since there is no colspan = 0, you can just do

 $('td[colspan]').not('[colspan=1]') 
+8
source

Use filter :

 var nodes = $('td[colspan]').filter(function() { return +$(this).attr('colspan') > 1 }); 

+ , added to $(this).attr('colspan') , converts a string to a number

+6
source
 var tds = $('td')​​​.each(function(){ if($(this).attr('colspan') > 1){ return $(this); } })​ 
+2
source

Source: https://habr.com/ru/post/918438/


All Articles