2017-04-20 5 views
1

人。 jQuery .setPropertyで属性のような関数を使うことはできますか?.setPropertyに属性のような関数を追加できますか?

jQuery(document).ready(function(){ 
jQuery(".content-wrapper").mouseenter(function(){ 
    jQuery(this).find('.separator-content-box').each(function(){ 
     this.style.setProperty('width', jQuery(jQuery('.content-wrapper').width() - jQuery('.heading').width()), 'important'); 
     this.style.setProperty('border-color', 'red', 'important'); 
    }); 
}); 
+0

はい!この「this.style.setProperty( 'width'、jQuery(jQuery( '。content-wrapper'))には、jQueryが追加されています。 '); " –

答えて

0

ご不明な点がありましたら、CSSとHTMLの関連情報をご提供ください。

jQueryでは、要素にインラインスタイルを追加するために'css() '関数を使用することをお勧めします。私はあなたのHTML/CSSの構造を知らないが、私は試してみましたテストがある

jQuery(document).ready(function(){ 
    jQuery(".content-wrapper").mouseenter(function(){ 
     jQuery(this).find('.separator-content-box').each(function(){ 
      jQuery(this).css('width',(jQuery('.content-wrapper').width() - jQuery('.heading').width())); 
      jQuery(this).css('border-color','red'); 
     }); 
    }); 
}); 

https://jsfiddle.net/97fjbp12/

注:あなたのコードは次のようなものでなければなりませんあなただけ(を追加必要な計算を行うにはをし、 )を有効にしてください。

関連する問題