Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/108.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery中的访问伪类_Jquery_Html_Css - Fatal编程技术网

Jquery中的访问伪类

Jquery中的访问伪类,jquery,html,css,Jquery,Html,Css,我需要这个按钮: <div class="myButton" id="clearBefore">Click Me</div> HTML 看起来您在HTML中使用了一个伪类,它不应该具有伪类的效果。您应该在CSS中使用它们: .ms-Label:before { content: "I am before"; } 就切换而言,如果我理解正确,您可以通过向标签添加一个类toggle,并将以前的选择器更改为.ms label。toggled:beforeHTML:

我需要这个按钮:

<div class="myButton" id="clearBefore">Click Me</div>
HTML


看起来您在HTML中使用了一个伪类,它不应该具有伪类的效果。您应该在CSS中使用它们:

.ms-Label:before {
  content: "I am before";
}
就切换而言,如果我理解正确,您可以通过向标签添加一个类
toggle
,并将以前的选择器更改为
.ms label。toggled:before
HTML:

   <div class="checkboxHiddenSelectContainer" data-toggle="filterList" style="display: block;">
     <div class="ms-ChoiceField">
        <input class="ms-ChoiceField-input">
        <label class="ms-ChoiceField-field"">
           :before
           <span class="ms-Label content1">Function</span>
           :after
        </label>
     </div>
    </div>
JS:


你在课堂上切换是什么意思?您的意思是将其添加到元素中吗?请澄清您的具体问题或添加其他详细信息,以突出显示您所需的内容。正如目前所写的,很难准确地说出你在问什么,你问什么是不可能的。我的回答应该澄清。
.ms-Label:before {
  content: "I am before";
}
   <div class="checkboxHiddenSelectContainer" data-toggle="filterList" style="display: block;">
     <div class="ms-ChoiceField">
        <input class="ms-ChoiceField-input">
        <label class="ms-ChoiceField-field"">
           :before
           <span class="ms-Label content1">Function</span>
           :after
        </label>
     </div>
    </div>
.content1:before {
content:'Old content'; 
}

.content2:before {
content: 'New content';
}
$('#clearBefore').click(function() {
  $('.ms-Label').removeClass('content1').addClass('content2');
  // if wanna toggle content
  // $('.ms-Label').toggleClass('content1').toggleClass('content2');
})