[英]Button colour not changing
Problem- Button colour is not changing, I used jquery click function 问题-按钮的颜色没有改变,我使用了jquery点击功能
<button class="red" id="MyQuotes" href="#" title="">@Aceo.Crm.App.Resources.Shared.Order.Link_MyQuote</button>
For this button i used jquery as 对于这个按钮,我使用jQuery作为
$(document).ready(function(){
$("#MyQuotes").click(function(){
$(this).css({background:"red"});
});
});
But it was not successfull, I tried to do this in this way too- 但这并不成功,我也尝试过这种方式-
<button class="red" onclick="D()" id="MyQuotes" href="#" title="">@Aceo.Crm.App.Resources.Shared.Order.Link_MyQuote</button>
I made javascript function here as- 我在这里做了javascript函数-
<script language="javascript">
function D()
{
document.body.style.backgroundColor="red";
}
</script>
And yes this time i was again failed. 是的,这次我再次失败了。 Can you please suggest me some codes?
你能给我建议一些代码吗?
Using jQuery: http://jsfiddle.net/DrWjq/ 使用jQuery: http : //jsfiddle.net/DrWjq/
$(document).ready(function(){
$("#MyQuotes").click(function(){
$(this).css({background:"red"});
});
});
Pure JS: http://jsfiddle.net/wx9tw/ 纯JS: http : //jsfiddle.net/wx9tw/
function D(id)
{
id.style.backgroundColor="red";
}
<button class="red" onclick="D(this)" id="MyQuotes" href="#" title="">@Aceo.Crm.App.Resources.Shared.Order.Link_MyQuote</button>
your selector's id is "MyQuotes" and not "MyOrders" 您选择器的ID是“ MyQuotes”,而不是“ MyOrders”
try this 尝试这个
$("#MyQuotes").click(function(){
$(this).css({background:"red"});
});
OR 要么
function D()
{
$('#MyQuotes').css({background:"red"});
}
You must refer the button (SO #MyQuotes not #MyOrders) in JS: 您必须在JS中引用按钮(因此,不是#MyQuotes,而是#MyQuotes):
$(document).ready(function(){
$("#MyQuotes").click(function(){
$(this).css({background:"red"});
});
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.