Anyone know how to get the offset of a character at a given position of its parent tag?
friends.I'd like to do something like this: A DIV in a web page contains some text,for example ,Hi,hello world ,and the position(100,100) of the page point to the char 'e'.I do not need which char it is but the offset of it,which means the place that 'e' stands in the whole sentense 'Hi,hello world'(Which is the content of its parent tag DIV).In this example,the offset is 4. 'H' for 1,'i' for 2,','for 3 and so forth.
Any one can help me?
An example:
var my_car="Ferrari";
var where_is_a=my_car.indexOf('a');
alert('The a is at position '+where_is_a+'.');
精彩评论