大佬教程收集整理的这篇文章主要介绍了jquery – 在点击raphael对象上添加类,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我试过这个
$('#inter-mapka a').click(function(){ $('#inter-mapka a').removeClass("active"); $(this).addClass("active"); });
但什么都没发生,我怎么能这样做
RAPHAEL
// A1 paper.path("M9,163.334 L12,163.25 L18.5,157 L80.958,192 L64.5,192 L9,177.084Z").attr({"fill":"#6e3315","stroke-width": 0,"fill-opacity": 0,"stroke": "transparent","title": "budynek A1"}).mouSEOver( function () { this.animate({"fill-opacity": .7},200); }).mouSEOut(function () { this.animate({"fill-opacity": .0},200); });
生成的HTML
<div id="inter-mapka"> <a title="budynek A1"><path style="fill-opacity: 0;" fill="#6e3315" stroke="none" d="M9,163.334L12,163.25L18.5,157L80.958,192L64.5,192L9,177.084Z" stroke-width="0" fill-opacity="0"/></a> ... </div>
编辑我已经重构了这个以简化http://jsfiddle.net/joevallender/v2Ykt/6/
var paper = new Raphael(document.getElementById('inter-mapka'),172,276); var a1 = paper.path("M9,177.084Z").attr({"title": "budynek A1"}); var a2 = paper.path("M3.875,141H38c0,7.75-3.875,10-8c0-4.5,0-18.5,0-18.5s0.375-5.625-11.125-5.625 s-30.719,0-30.719,0L6.125,110H5l-0.012,10.969L3.875,121V141z").attr({"title": "budynek A2"}); var a3 = paper.path("M81.125,93.188h-30c0,0-7.125-1.938-9.25-7.438c0-5.625,0-18.875,0-18.875 S42.503,61.75,48.001,61c5.624,33.124,0V93.188z").attr({"title": "budynek A3"}); var a4 = paper.path("M5,39.875l7.875,6H40.75c0,8.375-0.25,7.25-7.5c0-7.25,0.104-19,0.104-19L44,10H5V39.875z").attr({"title": "budynek A4"}); var a5 = paper.path("M80,10v30.375c0,1.125,5,6,5.5c4.875,28.75,0L118.875,40V10H80z").attr({"title": "budynek A5"}); var all = [a1,a2,a3,a4,a5]; for(var i = 0; i < all.length; i++) { all[i].attr({"fill":"#6e3315",'stroke': '#f00'}); all[i].mouSEOver( function () { this.animate({"fill-opacity": .7},200); }).mouSEOut(function () { this.animate({"fill-opacity": .0},200); }); all[i].click(function(){ clearAll(); this.attr({"stroke-width": 1}); }); } function clearAll(){ for(var i = 0; i < all.length; i++) { all[i].attr({"stroke-width": 0}); } }
以上是大佬教程为你收集整理的jquery – 在点击raphael对象上添加类全部内容,希望文章能够帮你解决jquery – 在点击raphael对象上添加类所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。