要素の幅を19px修正する必要があるとします。
find要素を作成し、見つかった要素をCSS-widthのように設定することは可能ですか?
$el.find( '.ui-content' )
.css({'width': "parseFloat(found_element_current_width) -19" })
そうでない場合、これを行うための最良の方法は何ですか?
要素の幅を19px修正する必要があるとします。
find要素を作成し、見つかった要素をCSS-widthのように設定することは可能ですか?
$el.find( '.ui-content' )
.css({'width': "parseFloat(found_element_current_width) -19" })
そうでない場合、これを行うための最良の方法は何ですか?
はい。
$el.find( '.ui-content' )
.width(function(i, width) { return width - 19; })
cssの関数を使用できます。
$el.find( '.ui-content' )
.css('width', function(i, w){
return (parseFloat(w) - 19) + 'px'
})
From the documentation of the .css() function:
As of jQuery 1.6,
.css()accepts relative values similar to.animate(). Relative values are a string starting with+=or-=to increment or decrement the current value. For example, if an element's padding-left was 10px,.css( "padding-left", "+=15" )would result in a total padding-left of 25px.
So you could just do:
$el.find( '.ui-content' )
.css('width', '-=19');
yes you can.
$el.find( '.ui-content' )
.css('width', parseInt(yourwidth) - 19)