147
rated 0 times
[
151]
[
4]
/ answers: 1 / hits: 17056
/ 11 Years ago, tue, october 29, 2013, 12:00:00
I'm trying to make a button that will replace the content of a li. I've searched other answers on here, but I get this error: Uncaught TypeError: Object li#element2 has no method 'replaceWith'
I've tried replaceWith, .html, and .text, but they all have the same Here's my page:
<html>
<head>
<script type=text/javascript src=http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js></script>
<script>
$(document).ready(function(){
$(#theButton).click(function(){
(li#element2).replaceWith(This is the second element)
});
});
</script>
</head>
<body>
<h1 id=header>The document header.</h1>
<p>Value: <input type=text id=theInput value= size=10>
<ul id=theList>
<li id=element1>Element 1
<li id=element2>Element 2
<li id=element3>Element 3
</ul>
<div id=theDiv></div>
<input type=button id=theButton value=click me!></p>
</body>
</html>
More From » jquery