Francis Stalin
Francis Stalin

Reputation: 449

how to change the css property of absolute position div with parent div id

<html>
<head>
<script src="jquery.min.js"></script>
</head>
<body>
 <div id="disp"> 
   <div>
      hi how are u
   </div>
   <div style="position:absolute;left:50px;top:100px;">
      hello
   </div>
 </div>
 <script type="text/javascript">
  $(function(){
    $("#disp").css({"background-color":"#00ff00"});
  });
  </script>
</body>
</html>

here it's giving blue color for "hi how are u" but it's not reflect in next div because it's in position:absolute how to make it part of parent div

Upvotes: 0

Views: 69

Answers (4)

Shahul Hameed P
Shahul Hameed P

Reputation: 11

Can try this also alert($("#show").html());

Upvotes: 0

Marz
Marz

Reputation: 381

I'm not sure I understand your question, but it looks to me like you need to do this:

$("#show").children();

This will return all the children DOM objects underneath the div with the ID "show". You can test it out by doing this command:

console.log($("#show").children());

This will post your objects to the console. Hope this helps!

Upvotes: 0

Jai
Jai

Reputation: 74738

use .text() instead:

alert($("#show").text());

Upvotes: 1

Explosion Pills
Explosion Pills

Reputation: 191819

.val is used for the value property of <input>s, the value of the selectedIndex option of <select>s, et. al.

I'm not sure exactly what you want, but I think you mean to use .html instead.

Upvotes: 1

Related Questions