vendredi 11 septembre 2015

Width of selected text - jquery

I'm trying to get the width of a selected text in pixels and show it as an alert();. Does this exist?

EDIT (copied it from the comment I wrote below)

I did many efforts but all went in vain, now i'm trying to see if I can get the value of selection.toString() and then bind it to .width() if i can manage to do it, i'm pretty sure i can combine them both to get the width I'm looking for.

EDIT 12:42 am

I tried this

if(selection.toString() != '' ){
    var selected = selection.toString();
    alert($(selected).width());
}

I get the value of null



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire