Hallo, bitte schauen Sie sich die HTML unten an. Ich versuche, jQuery zu verwenden, um mit class="box"
mit class="entry"
innerhalb des DIV enthielt jede dritte Instanz auf die DIVs zu bekommen, keine rechten Rand zu haben:jQuery: N-Kind() Selektor
Mein HTML-Code:
<div class="entry">
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box I Want to remove right hand margin on this div -->
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box I Want to remove right hand margin on this div -->
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box -->
<div class="box">
SOME HTML....
</div><!-- end .box I Want to remove right hand margin on this div -->
</div>
<!--end entry-->
Mein Versuch, mit jQuery:
<script>
$(document).ready(function(){
$("div.entry:nth-child(3)").css("margin", "0px");
});
</script>
Ich kann das nicht funktionieren kann jemand bitte helfen? Danke im Voraus!
Dank an alle, die geholfen haben, die Lösung zur Verfügung gestellt ist in der Tat richtig. Ich kodiere eine gelieferte Vorlage und stelle fest, dass JQuery im Kompatibilitätsmodus ausgeführt wurde, daher war $ das Problem.
Ich hatte das gleiche Problem auch. Ich habe in diesem Fall ein Container-Div, ".entry", erstellt und den Selektor 'div.entry> div.box:nth-child (3)' verwendet, der greate funktioniert hat. danke für die Hilfe –