我有一个jQuery插件,允许我使用Title="Full Name"
在我的表单的文本框中添加内嵌标签唯一的问题是我编写了一个javascript翻译器,将页面上的所有内容翻译成英语,法语,或者西班牙语。我也需要更新标题。
我已尝试使用document.getElementById
,但这不起作用。我猜是因为它在表格里面。这是构成我表格的html的副本。
<form id="signupform" method="post" action="login.php">
<div class="field"><input type="text" class="box" id="name" name="fullname" title="Full Name"></div>
<div class="field"><input type="email" class="box" id="email" name="useremail" title="Email Address"></div>
<div class="field"><input type="password" class="box" id="pass" name="password" title="Password"></div>
<div class="field"><input type="password" class="box" id="confirmpass" name="confirm" title="Confirm Password"></div>
<div id="lowersignuparea">
<table width="306" cellspacing="0" cellpadding="0" align="center">
<tr>
<td><span id="signuperror"><?php echo $signuperror ?></span></td>
<td width="87"><span><input type="submit" class="signupbutton" id="signupbtn" value="Sign Up" style="cursor:pointer;"></span></td>
</tr>
</table>
</div>
</form>
有关如何通过JavaScript更改文本框标题的任何想法?
感谢。 -Ryan
答案 0 :(得分:0)
您可以使用这样的javascript设置标题值。
document.getElementById("elementid").setAttribute("title", "my new title");
答案 1 :(得分:0)
您应该将代码包装在ready事件中,如下所示:
<script type="text/javascript">
$(document).ready(function() {
$('form input').each(function(){
var translated = translateYourTitlte($(this).attr('title'));
$(this).attr('title', translated);
});
});
</script>
您应该提供用于显示工具提示的插件名称。