

<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
<meta http-equiv="Content-Security-Policy" content="default-src * data: gap: https://ssl.gstatic.com; style-src * 'unsafe-inline'; script-src * 'unsafe-inline' 'unsafe-eval'">
<script src="components/loader.js"></script>
<script src="lib/onsenui/js/onsenui.min.js"></script>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></s …
<link rel="stylesheet" href="components/loader.css">
<link rel="stylesheet" href="lib/onsenui/css/onsenui.css">
<link rel="stylesheet" href="lib/onsenui/css/onsen-css-components.css">
<link rel="stylesheet" href="css/style.css">
<script>
var count = 0;
function increment() {
count++;
update();
}
function update() {
var str = ('0' + count).substr(-2);
$('img.counter-digit').each(function(i,e){ if (i<str.length) e.src = "img/noo_@.png".replace(/@/, str.charAt(i)) });
}
$(function() {
$('.count-button').on("touchend", increment);
update();
})
$(function() {
$('.count-button').on('.count-button','click',function(){
$(this).remove();
$('#sortable').append($(this).clone().addClass("ui-sortable-handle"));
});
});
function openYahoo(){
$(this).remove();
$('#unList').append($(this).clone().removeClass("ui-sortable-handle"))
}
setTimeout("openYahoo()", 3000);
</script>
以上のプログラムでcount-buttonを一度クリックするとopenYahooの実行によりボタンが消えるというプログラムを作成していたのですが、「uncaught TypeError:Cannot read property 'ownerDocument' of undefine」というエラーがあり、カウントはできるのですがボタンが消えてくれません
初歩的なことかもしれませんが助けてください。
No.2ベストアンサー
- 回答日時:
こんにちは
ざっと眺めただけで、確認はしていませんが・・・
>count-buttonを一度クリックするとopenYahooの実行により~
count-buttonのクリックでは、openYahoo()は実行されるようになっていないと思いますけれど??
関数openYahooが実行されるのは、最後の1行の
setTimeout("openYahoo()", 3000);
を処理しようとする時だけではないでしょうか?
しかもthisが定まっていないので、関数の中で$(this)として引用されているthisは一体何になっているのでしょうか?
(グローバルオブジェクトかな?)
想像するところ、そこでエラーになっているのではないでしょうか?
(実際のエラー発生個所は、jQuery内の解釈構文中かも知れませんが・・・)
ボタンを押してカウントした後に
openYahooが起動できるようにしたらいいんですかね?
私が修正しても思うように動いてくれないので
よかったらサンプルコードを記載していただけませんか?
お忙しいとは思いますが、お願いします
No.1
- 回答日時:
スタイルシートがやたら拡張されていてなんだかわかりません
HTMLとそれに対してどういうトリガーでどうしたいのか明示されたほうがよいでしょう
<body id="mainn">
<div class="page1_background">
<form name="zbotoon"method="post" action="zukann.html">
<button type="image" id="bottonz"><img src="img/zbotton.png"style="width:180px;height:120px"></button>
</form>
</div>
<button class="count-button"><img src="img/megane.png" width="100"height="50"style="position: relative;
top: 60px;right:50px;"></button>
<button class="count-button"><img src="img/megane.png" width="100"height="50"style="position: relative;
top: 100px;left:50px;"></button>
<div class="counter">
<img src="img/no_00.png" height="100"width="80" class="counter-digit" style="position: relative;
top: -200px;right:100px;">
<img src="img/no_00.png" height="100"width="80" class="counter-digit" style="position: relative;
top: -200px;right:155px;">
</div>
</body>
</html>
HTMLはこちらです。
お探しのQ&Aが見つからない時は、教えて!gooで質問しましょう!
関連するカテゴリからQ&Aを探す
おすすめ情報
デイリーランキングこのカテゴリの人気デイリーQ&Aランキング
-
サイトにアクセスした際、数秒...
-
jqueryのcolorboxを読込直後に...
-
スライド写真で2、3枚目をラ...
-
jqueryとlightboxが一緒に動作...
-
CKeditorについて
-
javaスクリプトについて質問で...
-
mootoolsとjQueryの共存がうま...
-
jQuery が動作しません。
-
Javascriptのエラーに悩まされ...
-
Base64に変換したHTMLの<script...
-
Google 自サイト検索結果 オー...
-
jquery select要素のdisplay:no...
-
base64encodeでの文字化けについて
-
javascriptとjuaryを同時に
-
javascript 引用符
-
bxslider、画像が3枚以上になる...
-
<div>のタッチ状態を維持したま...
-
ヤフーのジオの広告のような技法
-
Lightboxがエラーになります。
-
マスターページでのJavaScriopt...
マンスリーランキングこのカテゴリの人気マンスリーQ&Aランキング
-
サイトにアクセスした際、数秒...
-
jqueryプラグインの設置方法
-
javascriptの中でjavascriptを...
-
教えてください! lightboxとsk...
-
liteboxと滑らかスクロールが同...
-
補足です。
-
マウスオーバー+クリカブルマッ...
-
<head>外での、外部css、外部js...
-
jQuery UIのdraggableについて
-
base64encodeでの文字化けについて
-
document.lastChild.appendChil...
-
HTMLに記載したいjavascript
-
jQuery.lightpop.jsの動作について
-
Camera slideshowの使い方について
-
ライブラリについて
-
jqueryのcolorboxを読込直後に...
-
CrossSlideのスライドショーが...
-
thickboxで画像ギャラリーが表...
-
noscript内にlinkは間違い?
-
wordpressでJavascriptのフラッ...
おすすめ情報