Golanlan Posted September 24, 2006 Share Posted September 24, 2006 Let's say I've got: hello<br>dog<br>cat<br> How do I detect the start of each line so I could make it automatly: {1}hello<br>{1}dog<br>{1}cat<br> ? Link to comment Share on other sites More sharing options...
Webworldx Posted September 24, 2006 Share Posted September 24, 2006 An interesting one! I'm sure someone will come up with a better solution (RegExp test with a while loop that I couldn't quite manage...), but here's my idea: <div id='the_text'>hello<br>dog<br />cat<br></div><script type='text/javascript'>var my_div = document.getElementById('the_text')var my_div_matches = my_div.innerHTML.split(/<br(.*?)>/i);for(i=0;i<my_div_matches.length;i++){ my_div.innerHTML = my_div.innerHTML.replace( my_div_matches[i] , "{1}" + my_div_matches[i] );}</script> Obviously it's on a small scale - so don't know how it'll transfer into what you're doing. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now