I have a div that has an onBlur event attached to it but my event keeps running when I mouseover <p>'s and <a>'s etc. This is obvious to me why, but I dont' want it to happen.
I need to prevent that from happening so I came up with using another event on all of those "child" elements that calls event.cancelBubble = true;. I know I know...IE only, but that's the only crowd I need to worry about here.
My issue then becomes adding an onmouseout event to those elements (that are dynamically inserted to my div). I wanted to just do a replace for all ">" with "onMouseOut="event.cancelBubble=true;" but that would also grab the end tags as well. So I'm goign to need some kind of regex to ensure that I don't replace the ">" on the end tags. But as you may alraedy know...Feyd I knwo you do, I'm a total friggin' regex wannabe.
can someone help me out with this?
thx,
Burr
[solved] Need some regex help...
Moderator: General Moderators
[solved] Need some regex help...
Last edited by Burrito on Tue Mar 22, 2005 1:14 pm, edited 1 time in total.
- Chris Corbyn
- Breakbeat Nuttzer
- Posts: 13098
- Joined: Wed Mar 24, 2004 7:57 am
- Location: Melbourne, Australia
So this:
Would become what exactly?
I'm sure you don't need to apply it to all the <BR>'s and <b>'s and <i>'s etc do you? It's be complex to avoid it though.
EDIT: If ">" really IS all that you want to replace that would be easier with str_replace() surely? - Just use strrchr() to get the ending ">" and remove it first
Code: Select all
<div onBlur="e;something()"e;>
Text here, yada yada yada<br>
Dumty dumty dum.....<br>
<a href="e;*****"e;>Oh dear I've hit a link</a><p>
No worries a regex could fix it!</p>
</div>Code: Select all
<div onBlur="e;something()"e;>
Text here, yada yada yada<br>
Dumty dumty dum.....<br>
<a href="e;*****"e; onMouseout="e;event.cancelBubble=true"e;>Oh dear I've hit a link</a><p onMouseout="e;event.cancelBubble=true"e;>
No worries a regex could fix it!</p>
</div>EDIT: If ">" really IS all that you want to replace that would be easier with str_replace() surely? - Just use strrchr() to get the ending ">" and remove it first
Indeed it would, but I don't want to replace the end tags.d11wtq wrote:So this:
EDIT: If ">" really IS all that you want to replace that would be easier with str_replace() surely?
Ex:
Code: Select all
<span id="4b">this is in my span</span>Code: Select all
<span id="4b" onMouseOut="mystuff()">this is in my span</span onMouseOut="mystuff()">here's what he came up with:
Code: Select all
$newstuf = preg_replace('#(<\s*(?!/).*?)>#','\\1 onMouseOut="event.cancelBubble=true">',$gtdates['eventdesc']);thanks,
Burrito