次の問題があります。ユーザーがアンカーをクリックするたびに、1divの幅を設定する必要があります。このdivの幅は、別のdivから取得する必要があります。これを達成する方法は?
次のコードは機能しません(スクリプトはPHPエコー内にラップされていることに注意してください)。
jQuery(".geother").click(function(){
var pos=$("p.second").width() + "px";
jQuery("#headerRightContactPhone span").css(\'width\', pos);
}
編集(私も別のものが必要です、私は左の「geother」divCSSに適用したいと思います。これはposwidth + 230pxの負の値になります):
jQuery(".geother").click(function(){
var pos = $("p.second").width(); // don't need to use 'px'
jQuery("#headerRightContactPhone span").css('width', pos); // don't need escaping
$(this).css('left', ((230+pos)*-1) );
});