【问题标题】:How to alert the defined function in jquery [duplicate]如何在jquery中提醒定义的函数[重复]
【发布时间】:2015-03-28 12:27:59
【问题描述】:

如何提醒定义的函数:

function calPricing{ Text }

alert(calPricing());

它不工作。

【问题讨论】:

  • 这里的括号是怎么回事? o.O jQuery(this).val() == 'betteroption') {
  • 请先检查你的语法...打开你的控制台检查错误
  • 单选按钮应具有相同的名称,但具有相同的 ID。 ID 应该是唯一的

标签: javascript php jquery


【解决方案1】:

您可以使用jQuery测试是否检查了特定的一个,如下所示:

if ($("#radio1").prop("checked")) {
   // do something
}

// OR
if ($("#radio1").is(":checked")) {
   // do something
}

// OR if you don't have ids set you can go by group name and value
// (basically you need a selector that lets you specify the particular input)
if ($("input[name='radioGroup'][value='1']").prop("checked"))

可以通过如下方式获取组中当前选中的值:

$("input[name='radioGroup']:checked").val();

【讨论】:

  • if ($("#radio1").prop("checked")) { // 做点什么 } 它不适合我
猜你喜欢
  • 2014-08-16
  • 1970-01-01
  • 2014-02-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多