Label being treated as a div

Styphon

I have a div containing a label and 4 divs. I want some css and jQuery to affect the 4 child divs, but not the label, and so I wrote the following:

HTML:

<div class="score row-fluid">
    <label class="span8">Text...</label>
    <div class="span1"><img></div>
    <div class="span1"><img></div>
    <div class="span1"><img></div>
    <div class="span1"><img></div>
</div>

CSS

.score > div {
    cursor:pointer;
}

jQuery

$('> div', '.score').on('mouseenter', function() {
    if($(this).not('.score-selected')) {
        var $img = $(this).children('img');
        var point = $img.attr('src').lastIndexOf('.');
        var src = $img.attr('src').substring(0,point);
        var newSrc = src + "-hover" + $img.attr('src').substring(point);
        $img.attr('src', newSrc);
    }
})
.on('mouseleave', function() {
    if($(this).not('.score-selected')) {
        var $img = $(this).children('img');
        var point = $img.attr('src').lastIndexOf('.');
        var point2 = $img.attr('src').lastIndexOf('-hover');
        var src = $img.attr('src').substring(0,point2);
        var newSrc = src + $img.attr('src').substring(point);
        $img.attr('src', newSrc);
    }
});

However the label has a pointer cursor, and it fires the mouseenter/leave JavaScript.

I've created a fiddle here, and interestingly it's not firing the JavaScript on the fiddle, but it is still being affected by the css.

Does anyone know why this label is being treated as if it's a div?

cjd82187

Bootstrap is giving label the pointer, and your mouse events are being called on .score as well as > div. When you hover over the label, you are also hovering over .score

EDIT: I changed the logging on your JS fiddle, here http://jsfiddle.net/sEa5W/1/

The mouse enter isn;t getting fired from the label, but the mouse exit is being called when you hover over to the mouse label from one of the DIVs because you are exiting the DIV.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

position() being treated as a function

From Dev

Absolute path being treated as relative

From Dev

object being treated as uninitialised variable

From Dev

PetaPoco parameter being treated as literal

From Dev

Android: Button being treated as tableLayout?

From Dev

Absolute path being treated as relative

From Dev

Shell variable is being treated as command

From Dev

variable in SQL query being treated as column

From Dev

JQuery Variables for Arithmetic being treated as strings

From Dev

Swift mutable dictionary being treated as immutable

From Dev

string being treated as a number when using if statement

From Dev

How to save the name of the file if it is being treated in the script

From Dev

Backslashes being treated as escape character Python/Json

From Dev

An object is being treated as NoneType in Python 2.7.6

From Dev

How to save the name of the file if it is being treated in the script

From Dev

Array being treated as string by angular with loopback backend

From Dev

Static var being treated as let constant?

From Dev

Label ASP not being set

From Dev

Label not being changed properly

From Dev

Dart int and double being interned? Treated specially by identical()?

From Dev

html 5 attribute as array of object being treated as string

From Dev

Test code not being compiled and treated as non-test

From Dev

How to use a percent (%) in a LIKE without it being treated as a wildcard?

From Dev

Can't stop list dividers being treated as list items

From Dev

Bizarre bug in Python - variable being treated as global rather than local

From Dev

Two distinct objects are being treated the same when used as keys in an object

From Dev

adding a msvc flag starting with "/D" results in it being treated as an added definition

From Dev

Laravel 4 - public directory being treated as a route - image not showing

From Dev

UI-Router url section being treated as parameter on refresh

Related Related

  1. 1

    position() being treated as a function

  2. 2

    Absolute path being treated as relative

  3. 3

    object being treated as uninitialised variable

  4. 4

    PetaPoco parameter being treated as literal

  5. 5

    Android: Button being treated as tableLayout?

  6. 6

    Absolute path being treated as relative

  7. 7

    Shell variable is being treated as command

  8. 8

    variable in SQL query being treated as column

  9. 9

    JQuery Variables for Arithmetic being treated as strings

  10. 10

    Swift mutable dictionary being treated as immutable

  11. 11

    string being treated as a number when using if statement

  12. 12

    How to save the name of the file if it is being treated in the script

  13. 13

    Backslashes being treated as escape character Python/Json

  14. 14

    An object is being treated as NoneType in Python 2.7.6

  15. 15

    How to save the name of the file if it is being treated in the script

  16. 16

    Array being treated as string by angular with loopback backend

  17. 17

    Static var being treated as let constant?

  18. 18

    Label ASP not being set

  19. 19

    Label not being changed properly

  20. 20

    Dart int and double being interned? Treated specially by identical()?

  21. 21

    html 5 attribute as array of object being treated as string

  22. 22

    Test code not being compiled and treated as non-test

  23. 23

    How to use a percent (%) in a LIKE without it being treated as a wildcard?

  24. 24

    Can't stop list dividers being treated as list items

  25. 25

    Bizarre bug in Python - variable being treated as global rather than local

  26. 26

    Two distinct objects are being treated the same when used as keys in an object

  27. 27

    adding a msvc flag starting with "/D" results in it being treated as an added definition

  28. 28

    Laravel 4 - public directory being treated as a route - image not showing

  29. 29

    UI-Router url section being treated as parameter on refresh

HotTag

Archive