在我的上一篇文章中我有两个单独的输入框%和$ value看起来像我的代码:
$(document).ready(function(){
$(".changeImgvalue").click(functon(){
var type=$(this).attr("type");
if(type == 'per'){
$(this).attr({
"type":"amount",
"src":"content/Images/percent.png"
});
$("#monthlymippc").attr("onchange","javascript:monthlyMIPPcChanged(true);");
} else if(type == 'amount'){
$(this).attr({
"type" :"per";
"src":"content/Images/RedDoller.png"
})
$("#monthlymipamt").attr("onchange",onChange="javascript:monthlyMIPAmountChanged(true)")
}
})
})
这是我的旧代码,它有两个独立的输入字段,工作得很好。之后我在新设计中改变了。我设置了单个输入字段,我必须在点击更改代码上设置%和$ image看起来像
Traceback (most recent call last):
File ".\FTPSync.py", line 957, in makeConnection
File ".\ftpsyncwrapper.py", line 318, in connect
File ".\ftpsyncwrapper.py", line 290, in retryingCommand
File ".\ftpsyncwrapper.py", line 284, in call
File ".\lib2\ftplib.py", line 140, in connect
File ".\socket.py", line 500, in create_connection
gaierror: [Errno 11001] getaddrinfo failed
当我将图像%更改为$时,我不知道如何在单个输入字段中设置另一个值?任何想法?请帮帮我?真的卡住了吗?
< --NEW - >
在此代码中,没有ID只有名称
{{1}}
我的剧本:
我在代码中添加了额外的id,我创建了这个脚本而不是工作..
{{1}}
我的代码中有任何错误?
答案 0 :(得分:1)
<强> HTML:强>
<img src="Content/Images/percent.png" type="per" class="changeImg" style="cursor:pointer"/>
<强> Jquery的:强>
$(document).ready(function () {
$(".changeImg").click(function () {
var type = $(this).attr("type");
if (type == 'per') {
$(this).attr({
"type": "amount",
"src": "Content/Images/dollar.png"
});
$("#downpaymentpc").attr("onchange", "downPaymentAmountChanged(true);");
} else if (type == 'amount') {
$(this).attr({
"type": "per",
"src": "Content/Images/percent.png"
});
$("#downpaymentpc").attr("onchange", "downPaymentPcChanged(true);");
}
});
});
<强> HTML:强>
<img src="Content/Images/percent.png" type="per" class="changeImg" style="cursor:pointer"/>
<强> Jquery的:强>
$(document).ready(function () {
$(".changeImg").click(function () {
var type = $(this).attr("type");
if (type == 'per') {
$(this).attr({
"type": "amount",
"src": "Content/Images/dollar.png"
});
} else if (type == 'amount') {
$(this).attr({
"type": "per",
"src": "Content/Images/percent.png"
});
}
});
});