javascript - Focus on next paragraph in contenteditable div / Summernote -


i using summernote replicating medium editor.

when inserting images, allow them inserted own paragraph tag. no text can mixed in side paragraph tags image.

i give each paragraph image inside class of 'has-image'. want not allow user enter text inside of paragraph if has class.

if try click inside tag instead focus next paragraph.

any how this? have tried triggering click on next paragraph no luck:

$(document).on('click', '.has-image', function() {     $(this).next('p').click(); }); 

i can set text of next paragraph know selecting fine cant think of way place cursor inside.

jsfiddle example: http://jsfiddle.net/vxncm/5583/

u may need work range

$(document).on('click', '.has-image', function() {      r = document.createrange()     r.setstart($(this).next('p')[0],0);     window.getselection().removeallranges();     window.getselection().addrange(r); }); 

note: works modern browsers except ie.

for ie capability, check https://code.google.com/archive/p/ierange/


Comments

Popular posts from this blog

testing - Detect whether test has failed within fixture -

AbotX : How do you create a parallel crawler that stays on and can be added to at run time from new requests -

android - Create single AAR file from multiple modules using Gradle -