Hope someone can help me.
I am using the following code to add tags to an input field. However, when you add a tag, the whole path is included.
j('.ltags-add').click(function (event){ contents = j('#link-tags').val(); if ( contents != '' ) { sep = ', '; } else { sep = ''; } tag = j(event.target).text(); j('#link-tags').val( contents + sep + tag ); });
<span class="ltags-add">link 1</span> <span class="ltags-add">link 2</span>
When you press the space bar, it should return the text "link 1", but now it returns "http://www.example.com/create/link 1"
Does anyone have an idea why this is happening and what can I do about it?
Cheers, G.
jquery events text
Goose
source share