0

I have a text form field. It can be cloned/duplicated. It generates name tag like user[name][1][1],user[name][2][1],user[name][3][1] etc...

I want to append a link next to that text fields using jquery. I tried like this..

<script type="text/javascript">
$(function(){
 $('<a href="#">Example link</a>').insertAfter('input[name="user\[name\]\[\]\[\]"]')
});
</script>

But its not working. Can anyone help me?. Thanks

asked Nov 17, 2012 at 0:54

1 Answer 1

1

Per the jQuery selector docs, special characters need to be escaped with double backslash. For all of the elements at once you can use the startsWith selector and do:

$('input[name^="user\\[name\\]"]');

DEMO: http://jsfiddle.net/dpJZE/2/

API selector docs: http://api.jquery.com/category/selectors/

Read top paragraph regarding escaping

answered Nov 17, 2012 at 1:07
Sign up to request clarification or add additional context in comments.

1 Comment

Hello mate, But its not working when i duplicate the fields. Can you tell me whats wrong?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.