简体   繁体   English

.append:清除输入值onclick

[英].append: clear input value onclick

I have a bookmarklet that appends the body to bring up a little litebox. 我有一个小书签,可以附加身体以显示一个小盒子。 In that litebox there is a form. 在那个litebox中有一个表格。 When the user clicks on an input field I want the current value to disappear. 当用户单击输入字段时,我希望当前值消失。 This is what I have tried so far and it isn't working. 到目前为止,这是我尝试过的方法,但是没有用。

function runthis() {
$('body').append("<p><input type='text' name='story_price' value='Price' onClick='this.value=''' /><p>");}

I have also tried this and it doesn't allow my bookmarklet to show up: 我也尝试过此操作,但它不允许我的书签显示:

function runthis() {
$('body').append("<p><input type='text' name='story_price' value='Price' onClick='this.value=""' /><p>");}

Any thoughts on how I could possible clear the contents within the .append 关于如何清除.append中内容的任何想法

Thanks! 谢谢!

Escape your quotes 转义报价

("It is 'OK' to use single quotes inside double") (“在双引号内使用单引号是'确定'”)

('This isn't OK') - should be ('This isn\\'t OK') ('这不行')-应该是('这不行')

function runthis() {
$("body").append('<p><input type="text" name="story_price" value="Price" onClick="this.value=\'\'" /><p>');}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM