function insertQuestion(form) {
var x = "<img src='Images/plussigndisabled.jpg' width='30' height='30' alt='Look Up Previous Question' class='plusimage' name='plusbuttonrow'/><span id='plussignmsg'>(Click Plus Sign to look <br/> up Previous Questions)</span>" ;
if (qnum == <?php echo (int)$_SESSION['textQuestion']; ?>) {
$('#mainPlusbutton').html(x); // no need to create a jQuery object
}
//append rows into a table code, not needed for this question
}
<form id="QandA" action="<?php echo htmlentities($action); ?>" method="post">
<table id="question">
<tr>
<td colspan="2">
<a onclick="return plusbutton();">
<img src="Images/plussign.jpg" width="30" height="30" alt="Look Up Previous Question" class="plusimage" id="mainPlusbutton" name="plusbuttonrow"/>
</a>
<span id="plussignmsg">(Click Plus Sign to look up Previous Questions)</span>
</td>
</tr>
</table>
<table id="questionBtn" align="center">
<tr>
<th>
<input id="addQuestionBtn" name="addQuestion" type="button" value="Add Question" onClick="insertQuestion(this.form)" />
</th>
</tr>
</table>
</form>
上面的代码假设发生的是用户单击“添加问题”按钮,这会将问题编号附加到表格中。现在假设发生的是,如果在 jquery 函数中满足 if 语句,那么它假设将加号按钮图像替换Images/plussign.jpg
为Images/plussigndisabled.jpg
. 但它没有这样做。
所以我的问题是用另一个图像按钮替换图像按钮的最佳方法是什么?同样在文档准备功能中,我需要它返回显示Images/plussign.jpg
按钮。