i am working on this project where i press a button that will look for specific words in the textarea(may be move the cursor to that specific word). i tried many things but so far no luck.
here what i am trying to do.
$line ="<html>
<head>
<title>Drum studio home</title>
<body>
<img src="/images/fo.png" alt=""/>
</body>
</html> ";
the textArea is in php page, test.php
<textarea name="tvalue" id="tvalue">
<?php
echo $line . "\r\n";
?>
</textarea>
<input type="submit" value="find next" name="submit"/>
when i run test.php i will see the following inside the textarea.
<html>
<head>
<title>Drum studio home</title>
<body>
<img src="/images/fo.png" alt=""/>
<img src="/images/fo.png" alt="fo image"/>
</body>
</html>
**find next** --- this is the button
The find next button will find any image that has no alternative text.
I know i need js or jquery. I am new to this. so Don’t know really where to start. please help.
thanks
Solution 1: Find next empty
alt-attributeJavaScript
HTML
Demo
http://jsfiddle.net/rMqbW/
I’ve build this based on the accepted answer from this question:
jQuery Set Cursor Position in Text Area
Solution 2: Go through all HTML-tags
This is the updated JavaScript to skip through all HTML opening tags. I only posted the updated/new parts.
javaScript
Demo
http://jsfiddle.net/TmeV3/
This one uses a solution from How can i get cursor position in a textarea? and a regex from Create a Javascript RegExp to find opening tags in HTML/php template.