开发者

How to set value in a hidden field and hide a div using Javascript? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that i开发者_如何学运维t can be reopened, visit the help center. Closed 10 years ago.

i am newbie to javascript and i want to know how to set value in a hidden field using java script and how to hide a div using java script ?


how to set value in a hidden field using java script

Set the value for hidden field:

var el = document.getElementById('hidden field id');
el.value = 'some value';

and how to hide a div using java script

Hide a div:

var el2 = document.getElementById('div id');
el2.style.display = 'none';

You might want to peform either of those actions if some element gets clicked, you could do:

var btn = document.getElementById('button id');

btn.onclick = function(){
    var el = document.getElementById('hidden field id');
    el.value = 'some value';
}

where id can be set for an element like this:

<div id="myid">

Have a look at:

  • JavaScript Tutorial
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜