I’ve got the following problem. I need to set a width of one div every time user clicks on anchor. Width of this div should be taken from another div. How to achieve this?
Following code doesn’t work (please keep in mind, that script is wrapped inside PHP echo):
jQuery(".geother").click(function(){
var pos=$("p.second").width() + "px";
jQuery("#headerRightContactPhone span").css(\'width\', pos);
}
Edit (I also would need another thing, I’d like to apply to “geother” div CSS left, which would be negative value of pos width+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) );
});
Note
You should need to give
display: blockto yourspanor use any block element likediv,petc.