小编cpp*_*pit的帖子

jQuery选中单选按钮值

<form id="form1" name="form1" method="post" action="">
  <input type="checkbox" id="check1" value="radio" />
  <label>left</label>
  <input type="checkbox" id="check2" value="radio2" />
  <label>right</label>
</form>
Run Code Online (Sandbox Code Playgroud)

我想知道每次有人点击它时是否检查复选框,然后将变量设置为值yes.

if ($('#check1').attr('checked'); ){
var check1 = 'yes'; 
else 
var check1 ='no'
}
Run Code Online (Sandbox Code Playgroud)

这是我到目前为止,它不起作用我如何返回值

html javascript jquery

0
推荐指数
1
解决办法
575
查看次数

php preg_match返回计数

我有以下几个变量:

$texttofind = "story of a test";
$paragraph  = "the story of a test and a test paragraph used for
               testing the story of a test paragraph";
Run Code Online (Sandbox Code Playgroud)

我想preg_match();用来返回计数,在这种情况下将是2.任何想法?

php preg-match

0
推荐指数
1
解决办法
2474
查看次数

删除以特定字母/字符php开头的单词

这是一个简单的例子:

$correction = "game";
$text ="Hello this is an example of a $word that starts with a $dollar sign";
$text = str_replace("\$word",$correct,$text);
Run Code Online (Sandbox Code Playgroud)

如果我回复$ text,它会说:你好,这是一个以美元符号开头的游戏的例子.工作得很好.现在我希望能够将任何以美元符号开头的单词更改为游戏,这样它将改变所有以$开头的单词,并将它们转换为"游戏"这个单词的任何想法吗?

php regex

0
推荐指数
1
解决办法
1434
查看次数

使用php以这种格式返回json

{
    code: "AL",
    z: 3204
}, {
    code: "DZ",
    z: 35468
}, 
Run Code Online (Sandbox Code Playgroud)

试图返回类似的东西.我这样做:

$arr = array ('code'=>array('z'),'US'=>2233332,'c'=>3,'d'=>4,'e'=>5);

    echo json_encode($arr);
Run Code Online (Sandbox Code Playgroud)

php json

0
推荐指数
1
解决办法
39
查看次数

在表格的每一行之后添加一行

 $("table:visible").each(function() {
    $(this).find("tr").each(function(){

      var row='<tr><td>val</td></tr>';
$(row).insertAfter("#mytable tr:first");


        });

});
Run Code Online (Sandbox Code Playgroud)

我想在表格的每一行之后添加一行.我现在使用的是在第一行之后添加一行.例如:

我的桌子有五个.我运行这个js后会有10个.有什么建议吗?

javascript jquery html-table

-2
推荐指数
1
解决办法
61
查看次数

标签 统计

php ×3

javascript ×2

jquery ×2

html ×1

html-table ×1

json ×1

preg-match ×1

regex ×1