2017-11-11 19 views
1

こんにちは、私は持っている一つの要素には2つのCSSスタイル属性のスタイル内の第1およびjqueryの属性、CSS内の第二と私はそのような最初の 取りたい: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;">

答えて

1

まず、要素にスタイル要素が存在するかどうかを確認する必要があります。インライン属性に存在しない場合JQueryのCSSスタイルがレンダリングされます。要素インラインが常に優先されます。スタイル属性が要素で見つからない場合、jquery CSSはそのスタイルを置き換えます。

$(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

はこれをやってみてください:

style="height: 351px !important;" 
関連する問題