.html和 .text 不起作用
.html and .text not working
我想在javascript的html中显示一些整数值,但不幸的是.html和.text都不起作用
这是我的代码
<script type="text/javascript">
$(".total").text("<?php echo $row_price['product_price'] + $economy; ?>");
$('input:radio[name="shipping_type"]').change(function(){
if($(this).val() == "economy"){
$(".total").text("<?php echo $row_price['product_price'] + $economy; ?>");
}else{
$(".total").text("<?php echo $row_price['product_price'] + $fast; ?>")
}
});
</script>
通过检查源代码值是否成功进入 .text() 函数。 控制台上也没有显示任何错误.html
<tr>
<td class='radio-container'>
<input checked="checked" id="shipping_type_economy" name="shipping_type" type="radio" value="economy" />
</td>
<td><label for="shipping_type_domestic">Economy</label></td>
<td class='right'>
<span class="economy">10.20$</span>
</td>
</tr>
<tr>
<td class='radio-container'>
<input id="shipping_type_fast" name="shipping_type" type="radio" value="fast" />
</td>
<td><label for="shipping_type__fast">Fast</label></td>
<td class='right'>
<span class="fast">20.00$</span>
</td>
</tr>
<tr><td>TOTAL</td>
<td class="right" id="total"><span class="total"><span/></td>
</tr>
你的代码是正确的,只需将你的Jquery代码包装在$(document).ready(function(){..})块中,如下所示:-
$(document).ready(function(){
//Jquery Code
});
您正在使用 jQuery 语法,该语法要求您包含 jQuery 库。 jQuery是javascript之上的一个库。 http://jquery.com/,除此之外,代码需要包装在 doc ready 语句中。
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
....your code
});
</script>
相关文章:
- electronic BrowserWindow的最小高度和宽度在hide()show()方法之后不起作用
- 监视函数从服务返回不起作用,但作用域函数起作用
- 幻灯片滚动javascript不起作用
- 简单的javascript在Shopify中不起作用
- Recaptcha在IE7和IE8中不起作用
- Ember Data DS.Model's set函数不起作用
- JsFiddle上的鼠标事件不起作用
- 我的AngularJS表达式没有'不起作用
- <text区域>在我的html中包含event.keycode==13之后,wrap就不起作用了
- getDocument by id/get input text from button dons'不起作用
- 带有 AJAX 响应或 AJAX 响应的 IF 条件.响应.Text 不起作用
- 如果iframe在src(pdf或text)中有非html文档,则iframe中的onload不起作用
- Google Closure Linter 在 Sublime Text 2 for Windows 中不起作用
- .text () 和 .html() 在 Jquery 中不起作用
- .html和 .text 不起作用
- jQuery: $(element).text() 不起作用
- 挖空模板在使用 RequireJS 和 Require Text 的 IE 8 中不起作用
- $(this).find(“.text”)和(“.loading”)在AJAX成功函数内部不起作用
- jQuery 'text' 不起作用
- Jquery选择器-text等于-不起作用