• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 270
  • Last Modified:

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 ()
    {
    });
0
Tom Knowlton
Asked:
Tom Knowlton
  • 2
  • 2
2 Solutions
 
Shahzad Fateh AliWeb Solutions Architect & Technical Project Manager- VentureDive (Pvt) LtdCommented:
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 AliWeb Solutions Architect & Technical Project Manager- VentureDive (Pvt) LtdCommented:
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
 
Tom KnowltonWeb developerAuthor Commented:
thx
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now