0
위젯을 만드는 방법을 배우기 때문에 위젯을 배치 한 웹 사이트에서 경고 된 Hey를 클릭했을 때 위젯을 시작한 간단한 위젯부터 시작했습니다. 출처 웹 사이트. 그래서 여기 소스 웹 사이트 지금 여기자바 스크립트 위젯 작동을 시도 중
(function(){
var jQuery;
if (window.jQuery==undefined || window.jQuery.fn.jquery!=='1.8.1'){
var script_tag=document.createElement('script');
script_tag.setAttribute("type", "text/javascript");
script_tag.setAttribute("src","http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js");
if(script_tag.readyState){
script_tag.onreadystatechange=function(){
if(this.readyState=='complete' || this.readyState=='loaded'){
scriptLoadHandler();
}
};
}else{
script_tag.onload=scriptLoadHandler;
}
(document.getElementsByTagName("head")[0] || document.documentElement).appendChild(script_tag);
}else{
jQuery=window.jQuery;
main();
}
function scriptLoadHandler(){
jQuery=window.jQuery.noConflict(true);
main();
}
function main(){
$(document).ready(function($){
$('.widget').click(function(){
alert("Hey");
});
});
}
})();
의 코드는 웹 사이트
<script src="http://www.reflap.com/beta/assets/js/widget2.js"></script>
<a class="widget" href="#">Hey</a>
에 배치 할 수있는 위젯의 코드입니다하지만 클릭하면 헤이 아무 반응이 없습니다. 뭐가 문제 야? 누군가 나를 도와 줄 수 있습니까?
'$ ('. widget')을 클릭하십시오 (function() {alert ("Hey");});'이 $ ('. widget' 브라우저가 링크를 따라 가지 못하도록 막았습니다. ("Hey");) –