jquery - Set width of one div based on another -


i've got following problem. need set width of 1 div every time user clicks on anchor. width of div should taken div. how achieve this?

following code doesn't work (please keep in mind, script wrapped inside php echo):

jquery(".geother").click(function(){ var pos=$("p.second").width() + "px"; jquery("#headerrightcontactphone span").css(\'width\', pos); } 

edit (i need thing, i'd apply "geother" div css left, negative value of pos width+230px):

jquery(".geother").click(function(){    var pos = $("p.second").width(); // don't need use 'px'    jquery("#headerrightcontactphone span").css('width', pos); // don't need escaping    $(this).css('left', ((230+pos)*-1) ); }); 

jquery(".geother").click(function(){    var pos = $("p.second").width(); // don't need use 'px'    jquery("#headerrightcontactphone span").css('width', pos); // don't need escaping }); //  missed ');' here 

note

you should need give display: block span or use block element div, p etc.

jquery(".geother").click(function(){        var pos = $("p.second").width(); // don't need use 'px'        jquery("#headerrightcontactphone span").css({                      width: pos,                       display: 'block',                      left: '-' + (230+pos)                }); // don't need escaping     });  

Comments