Select An Element In Jquery With Two Attribiutes
https://jsfiddle.net/The95Chaps/2L4t9saq/92/ is my code var createGrid=function(s,i,a,e){for(var r=1;r',n=1;n
Solution 1:
You cannot use two attribute selectors at once.
But what you can do is to use one... So you get a collection of matching elements. Inside this collection, just find the one that is also matching the second attribute.
An .each()
loop will do.
var createGrid=function(s,i,a,e){for(var r=1;r<i+1;r++){for(var c="<span class='inline'>",n=1;n<s+1;n++){c=c+"<div class='pixels' x='"+n+"' y='"+r+"'></div>"}c+="</span>",$("#main").append(c)}$(".pixels").css("background-color","gray"),$(".pixels").css("width",a),$(".pixels").css("height",e)};
var modGrid = function(code){
for(var n=1;n<gridx+1;n++){
for(var i = 1; i<gridy+1; i++){
$("[x="+i+"]")
}
}
}
var gridx = 64var gridy = 64createGrid(gridx,gridy,1,1)
// To target the pixel at (10,10)
$("[y='10']").each(function(){
if($(this).is("[x='10']")){
$(this).css("background-color","blue");
}
});
.inline { display: block }
.pixels { display: inline-block }
#main {
font-size:0;
}
<scriptsrc="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script><divcanvas="canvas"id="main"></div>
Post a Comment for "Select An Element In Jquery With Two Attribiutes"