Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery selector by width

Would it be possible to select a table with a specific width ?

Thanks

like image 256
Hellnar Avatar asked Nov 22 '10 08:11

Hellnar


People also ask

How do I set the width of an element in jQuery?

jQuery width() Method The width() method sets or returns the width of the selected elements. When this method is used to return width, it returns the width of the FIRST matched element. When this method is used to set width, it sets the width of ALL matched elements.

What does size () method of jQuery returns?

The size() method returns the number of elements matched by the jQuery selector.

What jQuery effect alters the width of an element?

The jQuery outerWidth() and outerHeight() methods get or set the outer width and the outer height of the element respectively. This outer width and height includes padding and border but excludes the margin on the element.

Does jQuery width include padding?

jQuery outerWidth() Method The outerWidth() method returns the outer width of the FIRST matched element. As the image below illustrates, this method includes padding and border.


2 Answers

Use the filter() function:

$('table').filter(function() {
    return $(this).width() > 700;
});
like image 139
Eric Avatar answered Oct 19 '22 06:10

Eric


Yes like this:

$('table[width="700"]')

Or you can get all tables having width with whatever value like this:

$('table[width]')
like image 7
Sarfraz Avatar answered Oct 19 '22 06:10

Sarfraz