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

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -