div resize not working

When I hover over a div, the resizing of another div works if I hard code the width, but not if I try to base it upon the width of another div somewhere.

Please help!

    $('div.landmark_mainS').hover(
    function ()
    {
        var w = $('div.landmark_mainO').css("width");
        $('div.landmark_mainP').css("width", w);  //DOES NOT WORK
        $('div.landmark_mainP').css("width", "1557px");  //WORKS
    },
    function ()
    {
    });
LVL 5
Tom KnowltonWeb developerAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Shahzad Fateh AliSoftware ArchitectCommented:
Did you try this.
$('div.landmark_mainS').hover(
    function ()
    {
        var w = $('div.landmark_mainO').width();
        $('div.landmark_mainP').width(w);
    },
    function ()
    {
    });

Open in new window

0
Tom KnowltonWeb developerAuthor Commented:
Sorry, but that solution does not work.
0
santhimurthydCommented:
Below thing is workign fine for me

    <div id="dvContainer1" style="width:560px;">
    </div>
  <div style="width:200px;border-width:2px;border-style:solid;border-color:#123456;color:Red;" id="dvtarget">
            Value has been changed.
  </div>
        <script language="javascript" type="text/javascript">
            var divwidth = $("#dvContainer1").css("width");
            $("#dvtarget").css("width" , divwidth);
       </script>


In your case try with the alert for the variable "w" as whether your getting the value
0
Shahzad Fateh AliSoftware ArchitectCommented:
Here is the above code in working.. and it was working fine. I have tested it in IE and FF with latest version of jQuery.

<div style="background-color: #0000ff; width:250px; color:#ffffff;" class="landmark_mainO">This width will be used.</div>
<div style="background-color: #00ff00;" class="landmark_mainS">Hover me</div>
<div style="background-color: #ff0000;" class="landmark_mainP">
    TEST<br />
    TEST<br />
    TEST<br />
    TEST<br />
    TEST<br />
    TEST<br />
    TEST<br />
</div>
<script type="text/javascript">
$(function(){
    $('div.landmark_mainS').hover(
    function ()
    {
        var w = $('div.landmark_mainO').width();
        $('div.landmark_mainP').width(w);
    },
    function ()
    {
    });
})
</script>

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Tom KnowltonWeb developerAuthor Commented:
thx
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.