Cliff T Cliff T - 11 months ago 79
jQuery Question

replaceWith does not work with child class

I cant seem to make replaceWith work with a child class. Should I do this another way?

<li><input type="text" class="fn" value="Elvis"> <a href="#" class=".rmv" onclick="test()">test</a></li>

<li><input type="text" class="fn" value="Sam"> <a href="#" class=".rmv" onclick="test()">test</a></li>

function test() {

Answer Source

Just as sidenote - you're using the class on the anchor tags wrong - it should be

<a href="#" class="rmv">

instead of

<a href="#" class=".rmv">

As you're already using jQuery, you could just attach the click() event using jQuery like this:

$(document).ready(function () {
    $(".rmv").click(function (e) {
<script src=""></script>
        <input type="text" class="fn" value="Elvis" /> <a href="#" class="rmv">test</a>

        <input type="text" class="fn" value="Sam" /> <a href="#" class="rmv">test</a>