SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Sep 2008
    Posts
    341
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Crazy JS error makes no sense

    This makes no sense:

    http://page-test.co.uk/a.html

    It seems to have a problem because I'm removing the 'box' class. If I added other classes I can remove them, but not the 'box' one.

  2. #2
    Programming Team silver trophybronze trophy
    Mittineague's Avatar
    Join Date
    Jul 2005
    Location
    West Springfield, Massachusetts
    Posts
    16,992
    Mentioned
    186 Post(s)
    Tagged
    2 Thread(s)
    Error: TypeError: ele is undefined
    Source File: http://page-test.co.uk/a.html
    Line: 58
    Code:
    function hasClass(ele,cls) {
    	return ele.className.match(new RegExp('(\\s|^)'+cls+'(\\s|$)'));
    }
    I've never seen regex with "whitespace" or "beginning" .. "whitespace" or "end" written like that.
    Maybe try
    Code:
    RegExp('^(\\s)?'+cls+'(\\s)?$'));
    "beginning" maybe "whitespace" ..... maybe "whitespace" "end"


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •