1

I need to use JQuery to find

<div class="main-image content-fill" style="display:overflow"> 

in my HTML and replace it with

<div class="main-image content-fill" style="display:none">. 

I would appreciate all help in showing my how to do this. Also, I would like to apply window.onload if possible.

Thanks,

Jared

2
  • 4
    $('.main-image.content-fill').hide() Commented Jan 10, 2016 at 5:13
  • It is better to done with hide() then replace Commented Jan 10, 2016 at 5:14

4 Answers 4

2

if you want only hiding the div use hide or

use jquery css classes

$(document).ready(function(){
    $("button").click(function(){
        $(".div1").addClass("important");
    });
});

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("button").click(function(){
        $(".div1").addClass("important");
    });
});
</script>
<style>
.important {
   display:none;
}

</style>
</head>
<body>

<div class="div1">This is some text.</div>
<div id="div2">This is some text.</div>
<br>

<button>Add classes to first div element</button>

</body>
</html>

Sign up to request clarification or add additional context in comments.

Comments

1

This works for you.Its similar to the CSS property display:none.

$(document).ready(function(){
 $(".main-image content-fill").hide();
});

Comments

1

$(document).ready(function() {
    $('.main-image.content-fill').hide();
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="main-image content-fill" id="main-image content-fill" style="display:overflow">sdfsdf</div>

try this...

Comments

0

Use below code.

$(document).ready(function(){
    $('.main-image.content-fill').css('display','none');
});

<div class="main-image content-fill" style="display:overflow">gsdfsf</div>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.