i am using js to show/hide div when user clicks on tag .. but the problem is i want to use this function in multiple a tags and it's not working is that possible in javascript and i wont use jquery .
javascript :
function showdiv(id) {
var f = document.getElementById('sss_div');
if(f.style.display == 'none')
f.style.display = 'block';
else
f.style.display = 'none';
}
html:
<a class="class" href="javascript:void(0);" id="id" onClick="showdiv('sss_div')">click here </a>
here is the div :
<div id="sss_div" style="display:none;"><textarea></textarea></div>
any suggestions ??
var f = document.getElementById('sss_div');
只会选择'sss_div'元素,您应该使用参数ID。
var f = document.getElementById(id);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.