Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
156 views
in Technique[技术] by (71.8m points)

javascript - how do I know if two html elements (div, map or other) border?

I am creating a dynamic version of Risiko game and I have following question. Is there a way to make that automatically with html tags (map, div or others)? Also using javascript how I can find if two elements are adjacent?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

i will show with jquery.

for example :

if( $('element').css('border-width') > 0)

if you have more than 1 elements in same class use ID or just create another class. you can even do it like that :

for ( i = 0 ; i < $('element').length ; i++)
{
  if( $('element').eq(i).css('border-width') > 0)
  //create an array and push 0 and 1 s to that . could be helpful sometimes
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...