我有一个网页,其中一些内容是通过 javascript 函数调用添加的。页面上的某些项目分配有提示框。对于自显示页面加载提示框以来存在的那些。而对于动态添加的内容,它们不会显示。我使用 http://code.google.com/p/jquery-tipbox/downloads/list tipbox 工具
听起来这个问题没有例子就不清楚。所以,代码
<html>
<head>
<link rel="stylesheet" href="css/style.css" type="text/css">
<script src="js/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="js/jquery.tipbox.js" type="text/javascript"></script>
<script src="js/my_js_functions.js" type="text/javascript"></script>
<script type="text/javascript">
$().ready(function(){
$("#ele1_id").tipbox("tipbox message 1", 0);
$("#ele2_id").tipbox("tipbox message 2", 0);
$("#inc1").tipbox("tipbox message 3", 0);
$("#inc2").tipbox("tipbox message 4", 0);
});
</script>
</head>
<body>
<center>
<div style="visibility:visible" >
<input id='ele1_id' type='radio' name='test' value='test1'
onClick=get_fields(id,checked)
> test 1 option <br>
<input id='ele2_id' type='radio' name='test' value='test2'
onClick=get_fields(id,checked)
>test 2 option <br>
</div>
</div></td><td alighn=center>
<div style='visibility:hidden' id='parameters'></div>
<div style='visibility:hidden' id='parameters_extra'></div>
</center>
</body>
</html>
my_js_functions.js :
function add_fields(name,value){
var target=document.getElementById('parameters_extra');
var content2="";
if (name == 'ele1_id') {
if (value == 'sele1') {
content2="<table><tr><td id='inc1'>\
<b> text to which I want to have tipbox assigned (tipbox message 3) </b></td>\
<td><input type='text' maxlength=5 name='inp_value1' ></td></tr></table>";
}
else if (value == 'sele2') {
content2="<table><tr><td id='inc2'>\
<b> another text for which 'tipbox message 4' has to appear </b></td>\
<td><input type='text' maxlength=5 name='inp_value2' ></td></tr></table>";
}
}
target.innerHTML = content2;
target.style.visibility = "visible";
return false;
}
function get_fields(el,checked){
var target=document.getElementById('parameters');
var content;
var target2=document.getElementById('parameters_extra');
target2.style.visibility = "hidden";
if (checked){
if (el == 'ele1_id') {
content="<table><tr><td><b>select one of the options:</b></td><td>\
<select onChange=add_fields('ele1_id',this.options[this.selectedIndex].value) na
me='ele1_id'>\
<option selected='selected' value='None'>None</option>\
<option value='sele1'>Selection 1</option>\
<option value='sele2'>Selection 2</option>\
</select></td></tr></table>";
}
else if (el == 'ele2_id') {
content="<table><tr><td><b>select one of the options:</b></td><td> \
<select onChange=add_fields('ele2_id',this.options[this.selectedIndex].value)
name='ele2_id'> \
<option selected='selected' value='None'>None</option>\
<option value='sele1'>Selection A</option>\
<option value='sele2'>Selection B</option>\
</select></td></tr></table>";
}
target.innerHTML = content;
target.style.visibility = "visible";
}
return false;
}