我正在尝试删除动态附加的元素,但似乎未读取为此元素附加的类函数。
我可以单击+按钮并添加新元素,但是单击“-”按钮时不能删除。
<div id="dftenglist">
<label for="dtfeng">Name:</label><input type="text" class="dfteng">
<button id="plusdfteng">+</button>
</div>
$("#plusdfteng").click(function() {
$("#dftenglist").append('<br><span><label for "a">Name:</label><input type="text" class="dfteng"> <button class="minusbtn">-</button></span>');
});
$(".minusbtn").click(function() {
$(this).parent().remove();
})
Run Code Online (Sandbox Code Playgroud)
http://jsfiddle.net/0uv4k5bz/1/
谢谢亚历克斯
我有一个通用功能,可以通过电报机器人发送菜单(如下所示),但是我不知道如何在这些菜单上添加图标(mypokerbot的方式,检查图像)。有什么提示吗?
function SendGenericMenu ($chatid) {
$lista=array("A", "B", "C");
$text="Choose:";
global $bottoken;
$replyMarkup = array(
'keyboard' => $lista,
);
$encodedMarkup = json_encode($replyMarkup);
$content = array(
'chat_id' => $chatid,
'reply_markup' => $encodedMarkup,
'text' => "$text"
);
$ch = curl_init();
$url="https://api.telegram.org/bot$bottoken/SendMessage";
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($content));
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
// receive server response ...
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$server_output = curl_exec ($ch);
curl_close ($ch);
var_dump($server_output);
}
Run Code Online (Sandbox Code Playgroud)
我很难理解循环中的$ .get调用.在下面的例子中,我在一个函数内调用$ .get(我在$ .get上读取的文件对于这个问题无关紧要),它似乎在所有第一个循环完成后才被读取.
我希望控制台显示:
---
1
---
2
---
3
---
Run Code Online (Sandbox Code Playgroud)
但正在显示
1
2
3
4
5
6
7
8
9
10
---(11)
Run Code Online (Sandbox Code Playgroud)
你能告诉我为什么吗?
http://jsfiddle.net/qh6zn514/1/
<Button id="clickme">Click me</button>
$("#clickme").click(function() {
for ($i=0;$i<=10;$i++)
{
readNumber();
console.log($i);
}
})
function readNumber () {
$.get ("file", function(txt) {
console.log ("---");
});
}
Run Code Online (Sandbox Code Playgroud)