Note that there are some explanatory texts on larger screens.

plurals
  1. POUnable to get position() in JQuery $.each loop
    primarykey
    data
    text
    <p>I am trying to make an editable box (kind of a richTextBox) using html5 (contenteditable="true") and jquery. I need to find out position of each element inside the editable div so that I can insert a page break like microsoft word does. Here is the page</p> <pre><code>&lt;html xmlns="http://www.w3.org/1999/xhtml"&gt; &lt;head&gt; &lt;title&gt;jQuery Context Menu Plugin Demo&lt;/title&gt; &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8" /&gt; &lt;script src="http://code.jquery.com/jquery-1.7.2.min.js" type="text/javascript"&gt;&lt;/script&gt; &lt;script type="text/javascript"&gt; $(document).ready( function() { $("#divEdit").keyup(function(){ $.each($("#divEdit").find("*"), function(i,item){ alert(item.position()); }); }); }); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;jQuery Context Menu Plugin and KendoUI Demo&lt;/h1&gt; &lt;div style="width:740px;height:440px" contenteditable="true" id = "divEdit"&gt; &lt;p&gt; &lt;img src="http://www.kendoui.com/Image/kendo-logo.png" alt="Editor for ASP.NET MVC logo" style="display:block;margin-left:auto;margin-right:auto;" /&gt; &lt;/p&gt; &lt;p&gt; Kendo UI Editor allows your users to edit HTML in a familiar, user-friendly way.&lt;br /&gt; In this version, the Editor provides the core HTML editing engine, which includes basic text formatting, hyperlinks, lists, and image handling. The widget &lt;strong&gt;outputs identical HTML&lt;/strong&gt; across all major browsers, follows accessibility standards and provides API for content manipulation. &lt;/p&gt; &lt;p id="para"&gt;Features include:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;Text formatting &amp; alignment&lt;/li&gt; &lt;li&gt;Bulleted and numbered lists&lt;/li&gt; &lt;li&gt;Hyperlink and image dialogs&lt;/li&gt; &lt;li&gt;Cross-browser support&lt;/li&gt; &lt;li&gt;Identical HTML output across browsers&lt;/li&gt; &lt;li&gt;Gracefully degrades to a &lt;code&gt;textarea&lt;/code&gt; when JavaScript is turned off&lt;/li&gt; &lt;/ul&gt; &lt;p&gt; Read &lt;a href="http://www.kendoui.com/documentation/introduction.aspx"&gt;more details&lt;/a&gt; or send us your &lt;a href="http://www.kendoui.com/forums.aspx"&gt;feedback&lt;/a&gt;! &lt;/p&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p></p> <p>The problem is that alert(item.position()) is not fetching anything. The error that comes in firefox developer toolbar is 'item.position is not a function'. My guess is that it has to do something with the type of each element in $("#divEdit").find("*") as all the elements are different. Any help would be appreciated. Thanks</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload