0

Ive been trying to figure out how to get some data i type into a text field to save on the screen underneath it. Something like a twitter, or Facebook news nothing fancy. I'm using JQM and would like this to get save on the same page as the text field and button under the

<div data-role="content"> 

This is what i have for a field and button.

<input type="text" id="Text"/>
<input type="button" id="Button" value="Submit" />
<div id="buttonPlaceHolder">&nbsp;</div>

and this is some javaScipt i found to go along with the button, it works however the dollar signs screw up JQM and ive tried putting it in its own js file. I think i might be doing something wrong.

$('#Button').bind('click', function() {
$('#buttonPlaceHolder').append($('#Text').val());

// refresh jQM controls
$('#home').trigger('create');
});

If at all possible id like the javascript in with the html via script

4

1 回答 1

0

我不确定我是否理解了这个问题。尽管如此,试试这个,它可能会有所帮助:

<!DOCTYPE html>
<html>
<body>

<h1>My Web Page</h1>

<p id="demo">A Paragraph.</p>

<p id="myDIV">A DIV.</p>

<button type="button" onclick="myFunction()">Try it</button>

<script>
function myFunction()
{
document.getElementById("demo").innerHTML="Hello Dolly";
document.getElementById("myDIV").innerHTML="How are you?";
}
</script>

</body>
</html>

这是一个html页面示例。你可以在这里找到更多信息和有用的例子:http: //www.w3schools.com/js/js_examples.asp

如果您想保存以备后用,请尝试使用 localStorage 机制。

于 2012-09-05T10:11:52.280 回答