Jared Caputo
Jared Caputo

Reputation: 145

Find and replace HTML using JQuery

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

Upvotes: 1

Views: 97

Answers (4)

varun aaruru
varun aaruru

Reputation: 2940

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>

Upvotes: 2

Jakir Hossain
Jakir Hossain

Reputation: 2517

Use below code.

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

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

Upvotes: 0

Gautam Jha
Gautam Jha

Reputation: 1473

$(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...

Upvotes: 1

Wasiq Muhammad
Wasiq Muhammad

Reputation: 3138

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

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

Upvotes: 1

Related Questions