怎样用jquery removeclass拿到class

下次自动登录
现在的位置:
& 综合 & 正文
如何用Jquery获取某一个Div的Class或者ID
有一个Div,我想获取其ID或者Class值。
那么我可以先定位到这个DIV,然后采用attr方法来获取其值:
假如说:有一段Html:
&div class="comment" id="22"&
&div class="comment_detail" style="display: "&
&div class="comment_my"&&textarea class="comment_text" style="height: 16 "&&/textarea&&/div&
&div class="comment_text_bottom" style="display: "&
&div class="comment_emotion"&&a href="javascript:void(0)" class="comment_emotion_button"&表情&/a&
&div class="comment_emotion_detail" style="display: "&
&div class="comment_publish"&&input class="submit" type="submit"
value="评论"&&/div&
&div class="comment_bar"&&a href="javascript:void(0)" class="comment_click"&&/a&&/div&
如果我想从submit处定位,获取到comment处DIv的ID,那么我就可以这样办:
$(".submit").parent().parent().parent().parent().attr('id');
其值为:22;
CLASS值为:
$(".submit").parent().parent().parent().parent().attr('class')
&&&&推荐文章:
【上篇】【下篇】jquery 怎么获取class值_百度知道
jquery 怎么获取class值
提问者采纳
class&quot.attr(&quotvar classvalue=$(&#id&);/);&#47
其他类似问题
为您推荐:
jquery的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁jquery 同一个class,如何获取高度最高的那个的数值赋给其他? - 开源中国社区
当前访客身份:游客 [
当前位置:
使用jquery。
同一个class,但高度有可能不一样,我想比较哪个最大,然后把最大的高度赋给所有同一个class。
请问高手需要怎么写???
假设class=“box”
感谢大家~~~
共有3个答案
<span class="a_vote_num" id="a_vote_num_
自己摸索出答案了。。
$(window).load(function(){
var max_height=0;
$('.box').each(function(){
if( $(this).height() & max_height ){
max_height= $(this).height();
$('.box').css("height",max_height);
<span class="a_vote_num" id="a_vote_num_
$(window).load(function(){
var $box =&$('.box');
$box.height(Math.max.apply(null, $box.map(function(){
return $(this).height();
<span class="a_vote_num" id="a_vote_num_
//帮你省略点代码,哈哈
$(function(){
var max_height=0;
$('.box').each(function(){
max_height=$(this).height() & max_height?$(this).height():max_
}).height(max_height);
--- 共有 3 条评论 ---
: 看错,缩进不一致害死人
(1年前)&nbsp&
: 有什么bug呀
(1年前)&nbsp&
你这有bug吧...省代码也不是这么省的
(1年前)&nbsp&
更多开发者职位上
有什么技术问题吗?
深山大萝卜的其它问题
类似的话题当一个div有多个class时,用jquery怎么判断这个div中是否存在某一个class
少年同盟dd摇
if($("div").hasClass("classname")){}
为您推荐:
扫描下载二维码jquery 怎么根据 一个dom对象的class 得到这个对_jquery吧_百度贴吧
&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&签到排名:今日本吧第个签到,本吧因你更精彩,明天继续来努力!
本吧签到人数:0成为超级会员,使用一键签到本月漏签0次!成为超级会员,赠送8张补签卡连续签到:天&&累计签到:天超级会员单次开通12个月以上,赠送连续签到卡3张
关注:25,343贴子:
jquery 怎么根据 一个dom对象的class 得到这个对收藏
jquery 怎么根据 一个dom对象的class 得到这个对象的id
我知道你最爱的口味,知道你最爱用的香水,却偏不知这问题的答案
没有吧友解答么!?!?
$(".className")
学雷锋,做好事儿,看完帖,留个名,坐等解答。
upup~hoho~ddddd
登录百度帐号推荐应用
为兴趣而生,贴吧更懂你。或

我要回帖

更多关于 jquery addclass 的文章

 

随机推荐