选择具有特定宽度的div [英] Select div with specific width

查看:111
本文介绍了选择具有特定宽度的div的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

快速问题:
如何选择具有一定宽度的div。例如,我们在一个页面中有10个div,我想选择一个宽度为200px的页面并执行某些操作。
非常感谢。

解决方案

JCOC611表示:

< pre $ var $ theDivs = $('div')。filter(function(){return $(this).width()=== 200;});

这会为您提供一个jQuery对象,其中包含所有匹配的(200px)div。可能不是世界上最快的事物;如果可以的话,它可能会更好地直接和明确地识别您的页面元素。


Quick Question: How to select a div with certain width. For example we have 10 div in one page, I want to select the one that has 200px width and do something. Thanks a lot.

解决方案

What JCOC611 said:

var $theDivs = $('div').filter(function() { return $(this).width() === 200; });

That'd get you a jQuery object with all matching (200px) divs in it. Might not be the fastest thing in the world; it'd probably be better to more directly and explicitly identify your page elements, if you can.

这篇关于选择具有特定宽度的div的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆