jquery - Remove text after element -


i trying remove text after icon.

<i class="flagstrap-icon flagstrap-as" style="margin-right: 10px;">x</i>france  $('.flagstrap-icon').next().remove(); 

the problem next() not work without element.

example <span>france</span>

demo

any idea remove text after icon?

jquery can't target nodes aren't elements, plain js can

$('.flagstrap-icon').get(0).nextsibling.remove() 

fiddle

note uses native remove(), not supported in older browsers, if have support those, you'd do

var node = $('.flagstrap-icon').get(0).nextsibling; node.parentnode.removechild(node); 

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -