在页面中的另一个按钮上创建按钮单击
Creating Button in a page upon another button click
我是 HTML 和 JS 的新手,所以如果有人在以下方面帮助我,我将不胜感激 - 我有一个包含加号 (+) 按钮的普通页面:
<button style="background-color:#0099CC" id= "firstbutton" type="submit" data-role="button" data-theme="b">Add
<script>
$(function(){
$('#firstbutton').click(function(){
$(this).before('<button type="submit">add</button>');
});
});
</script>
我想在单击添加按钮时在添加按钮上方添加另一个按钮。有帮助吗?
使用以下 jquery 代码:
$("button").click(function(){
$(this).parent().prepend("<button style=\"background-color:#0099CC\">Add</button>");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button style="background-color:#0099CC" id= "firstbutton" type="submit" data-role="button" data-theme="b">Add</button>
使用 jquery 这是一个 javascript 库,您需要先 download 它或者您可以将其包含在 HTML
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
在上面包含的脚本标签内完成后:
<script>
$(function(){
$('#firstbutton').click(function(){
$(this).before('<button type="submit">add</button>');
});
});
</script>
我是 HTML 和 JS 的新手,所以如果有人在以下方面帮助我,我将不胜感激 - 我有一个包含加号 (+) 按钮的普通页面:
<button style="background-color:#0099CC" id= "firstbutton" type="submit" data-role="button" data-theme="b">Add
<script>
$(function(){
$('#firstbutton').click(function(){
$(this).before('<button type="submit">add</button>');
});
});
</script>
我想在单击添加按钮时在添加按钮上方添加另一个按钮。有帮助吗?
使用以下 jquery 代码:
$("button").click(function(){
$(this).parent().prepend("<button style=\"background-color:#0099CC\">Add</button>");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button style="background-color:#0099CC" id= "firstbutton" type="submit" data-role="button" data-theme="b">Add</button>
使用 jquery 这是一个 javascript 库,您需要先 download 它或者您可以将其包含在 HTML
<script src="http://code.jquery.com/jquery-1.11.3.min.js"></script>
在上面包含的脚本标签内完成后:
<script>
$(function(){
$('#firstbutton').click(function(){
$(this).before('<button type="submit">add</button>');
});
});
</script>