2017-11-11 2 views
1

Hallo ich habe zwei CSS-Stil ein Element für die erste innerhalb Attributs Stil und die zweiten innerhalb des jquery Attributs CSS und ich die ersten wie das nehmen will:nehmen erstes Element von CSS


$(document).ready(function() { 
 

 
\t jQuery(".iview-group-19").iView({ 
 
\t \t captionSpeed: 500, // speed to show caption 
 
\t \t captionOpacity: 1, // caption opacity 
 
\t \t captionEasing: 'easeInOutSine', // caption transition easing effect, use JQuery Easings effect 
 
\t \t customWidth: 1920, 
 
\t \t customHtmlBullet: false, 
 
\t \t rtl: false, 
 
\t \t height:500, 
 

 
    }); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> 
 
<div class="iview iview-group-19" id="slide-height" style="height: 351px;">

Antwort

1

Zuerst müssen Sie überprüfen, ob das Element style existiert oder nicht. Wenn nicht im Inline-Attribut vorhanden. JQuery CSS-Stil wird gerendert. Inline-Elemente haben immer die erste Priorität. Wenn das Attribut style im Element fehlt, ersetzt jquery css diesen Stil.

$(function(){ 
 

 
if(!$("h1").attr("style")){ 
 
\t \t $("h1").css({ 
 
\t \t \t \t \t "margin":"7px", 
 
\t \t \t \t \t "border":"10px solid red !important", 
 
\t \t \t \t \t "padding":"10px" \t 
 
\t \t }); 
 
} 
 

 

 
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> 
 
<h1 style="margin:1px;border:1px solid red;padding:10px;" > 
 
Hello test 
 
</h1>

0

versuchen dies zu tun:

style="height: 351px !important;"