class="article_content clearfix">
class="htmledit_views">
class="line mt-10 q-content" style="margin-top:10px; margin-bottom:0px; padding:0px; font-family:arial,'courier new',courier,宋体,monospace; white-space:pre-wrap; word-wrap:break-word; word-break:break-all; color:rgb(51,51,51); font-size:14px; line-height:24px">比如 <div class="home current">home</div> 这个 div 的class 里两个值一个是 home 一个是 current,现在我想要 jquery 只获取其中的一个,通过某种方法只返回 home 或是 class,如何实现?
class="line mt-10 q-content" style="margin-top:10px; margin-bottom:0px; padding:0px; font-family:arial,'courier new',courier,宋体,monospace; white-space:pre-wrap; word-wrap:break-word; word-break:break-all; color:rgb(51,51,51); font-size:14px; line-height:24px">
class="line mt-10 q-content" style="margin-top:10px; margin-bottom:0px; padding:0px; font-family:arial,'courier new',courier,宋体,monospace; white-space:pre-wrap; word-wrap:break-word; word-break:break-all; color:rgb(51,51,51); font-size:14px; line-height:24px">class="best-text mb-10" style="margin-top:0px; margin-bottom:10px; padding:0px; font-family:arial,'courier new',courier,宋体,monospace; white-space:pre-wrap; word-wrap:break-word; color:rgb(51,51,51); font-size:14px; line-height:24px; background-color:rgb(241,254,221)">var val=$("div").attr("class");//这里获取class值 var array=val.split(" ");//split双引号里面是空格,把class值用空格分开,转换为数组 那么,array[0]就获得home; arrya[1]获得class