I want when page loads , <div> be disabled and when button clicked <div> enabled.

How do I do it ? Can we do it using javascript ?

Can JQuery be used here ?how?

benzittlau
—
2010-06-21T04:10:26Z —
#2

Alternatively, to ensure that the div is hidden when the page first loads you can hide it using the css for your page. If you don't have css for the page you would need to place <style> tags around this codebyte.

idx1 {

display: none;

}

fattyjules
—
2010-06-21T04:31:55Z —
#3

benzittlau said:

Alternatively, to ensure that the div is hidden when the page first loads you can hide it using the css for your page. If you don't have css for the page you would need to place <style> tags around this codebyte.

#idx1 { display: none;}

The problem with doing it this way is that if the client doesn't have javascript enabled, they can't make the element appear, and probably won't even realise that something is missing.

fattyjules
—
2010-06-19T05:12:53Z —
#4

Change your input to;

<input type="button" value="enableDiv" id="myButton" />

Put this javascript in the page (will need <script> tags if you don't already have them);

$("#myButton").click(function() {
$("#idx1").toggle();
});

Should work (assuming you already have jQuery loaded).

fattyjules
—
2010-06-19T06:35:30Z —
#5

Whoops, forgot that you wanted the <div> hidden to start with. Put this before the javascript I supplied;