サポート » 使い方全般 » jQueryがうまく動かない

  • 解決済 takukawa24p

    (@takukawa24p)


    はじめまして
    FitTextというjQueryを入れようとしましたが
    どうやっても全く動かずいろいろググっても解決せず・・・

    ソースコードは以下の通りです
    head.php

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml" <?php language_attributes(); ?>>
        <head profile="http://gmpg.org/xfn/11">
            <meta http-equiv="Content-Type" content="<?php bloginfo('html_type'); ?>; charset=<?php bloginfo('charset'); ?>" />
            <meta http-equiv="X-UA-Compatible" content="IE=8 ; IE=9" />
            <title><?php wp_title('«', true, 'right'); ?> <?php bloginfo('name'); ?></title>
            <link rel="stylesheet" href="<?php bloginfo('stylesheet_url'); ?>" type="text/css" media="screen" />
            <link rel="stylesheet" href="<?php TEMPLATEPATH . '/style.css' ?>" />
            <link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> RSS Feed" href="<?php bloginfo('rss2_url'); ?>" />
            <link rel="alternate" type="application/atom+xml" title="<?php bloginfo('name'); ?> Atom Feed" href="<?php bloginfo('atom_url'); ?>" />
            <link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
            <link rel="shortcut icon" href="../favicon.ico" type="image/x-icon"/>
            <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7/jquery.min.js"></script>
            <script src="/jquery.fittext.js"></script>
    <script>
    $(function(){
        $("diaryname").fitText(1.2);
    });
    </script>
            <?php wp_head(); ?>
        </head>

    jquery.fittext.jsファイルは
    テーマフォルダの中に入れています

    ご教授お願いしますm(_ _)m

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • WordPress で jquery を使う場合は、no conflict mode で使用する必要があります。

    詳細は公式マニュアルをごらんください。
    http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers

    Note: The jQuery library included with WordPress loads in “no conflict” mode. This is to prevent compatibility problems with other javascript libraries that WordPress can load.

    In “no-confict” mode, the $ shortcut is not available and the longer jQuery is used. For example:

    $(document).ready(function(){
    $(#somefunction) …
    });
    Becomes:

    jQuery(document).ready(function(){
    jQuery(#somefunction) …
    });

1件の返信を表示中 - 1 - 1件目 (全1件中)
  • トピック「jQueryがうまく動かない」には新たに返信することはできません。