logo

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ
No Result
View All Result
logo
No Result
View All Result
Trang chủ mediawiki:common

MEDIAWIKI:COMMON

by Admin _ April 25, 2022

I need help with a script to lớn place different nội dung in a div depending on whether the page body tag has a class of "home" or not.

I am trying to use .hasClass & .html khổng lồ achieve this. It seems like it should be extremely straightforward, but I can"t figure it out. Lack of proper syntax knowledge? Incorrect declarations? I don"t know, và am hoping someone can point me in the right direction!

if ($("body").hasClass("home") == true) ("#mobilemenu").html("HOME"); else ("#mobilemenu").html("NOT HOME"); the JSFiddle (which currently does nothing) is here: http://jsfiddle.net/aqyN4/

Links to lớn other JSFiddles or questions with similar functions extremely welcome!

Thank you,

Ali

jquery class nói qua Improve this question Follow edited Jul 6 "12 at 15:10
*

Greg Pettit 10.3k33 gold badges4747 silver badges6868 bronze badges asked Jul 6 "12 at 15:07
*

IlaIla 3,18888 gold badges4141 silver badges7474 bronze badges 3 showroom a comment |

2 Answers 2

Active Oldest Votes15you forgot $ before ("#mobilemenu") :

if ($("body").hasClass("home")) $("#mobilemenu").html("Alle Kategorien- HOME");else $("#mobilemenu").html("NOT HOME");​demo : http://jsfiddle.net/aqyN4/4/

nội dung Improve this answer Follow answered Jul 6 "12 at 15:09
*

mgraphmgraph 14.7k44 gold badges3636 silver badges7272 bronze badges 1 địa chỉ cửa hàng a comment | 3hasClass already tests for a true value, you don"t need to lớn make a comparison.

Bạn đang xem: Mediawiki:common

Bạn vẫn xem: Jquery kiểm tra if element has class attached

Also, the ("#mobilemenu") tags did not have jQuery"s $ appended. This makes it an undeclared function. Also...you cannot xuất hiện a statement with " và use it to lớn encase strings unless you escape it, or use apostrophes. See working code below.

if ($("body").hasClass("home")) $("#mobilemenu").html("HOME");else $("#mobilemenu").html("NOT HOME"); cốt truyện Improve this answer Follow answered Jul 6 "12 at 15:09

*

OhgodwhyOhgodwhy 44k88 gold badges5959 silver badges9292 bronze badges địa chỉ a comment |

Your Answer

Thanks for contributing an answer khổng lồ Stack Overflow!

Please be sure to lớn answer the question. Provide details và share your research!

But avoid …

Asking for help, clarification, or responding to lớn other answers.Making statements based on opinion; back them up with references or personal experience.

Xem thêm: Cách Cài Đặt Và Chơi Fifa 2020 Mobile Trên Pc/Mobile, Download Fifa 20 Full Crack Miễn Phí Cho Pc

To learn more, see our tips on writing great answers.

Draft savedDraft discarded

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using email and Password Submit

Post as a guest

Name e-mail Required, but never shown

Post as a guest

Name thư điện tử

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy và cookie policy

Not the answer you're looking for? Browse other questions tagged jquery class or ask your own question.

The Overflow Blog Featured on Meta Linked-1How khổng lồ mark current navbar-element as active in bootstrap và don`t lost it when screen will be updated? Related 431 How to detect a textbox's content has changed 118 jQuery - If element has class bởi this 2 If parent class has X then vì this, else this 2 code works in jsfiddle but not in html document 0 Update jQuery Cycle Pager onLoad 0 HighCharts, multiple charts on page điện thoại tư vấn via function 0 None of my CSS or JavaScript is modifying the tag 1 Animate whole thực đơn before going to url, with jquery 2 if this class contains, then hide other class nội dung Hot Network Questions more hot questions

Question feed Subscribe to lớn RSS Question feed to subscribe to this RSS feed, copy và paste this URL into your RSS reader.


*

Share Tweet Linkedin Pinterest
Previous Post

How to check whether a checkbox is checked in jquery?

Next Post

Làm cách nào để mở cửa sổ phương thức bootstrap bằng jquery?

CÙNG CHUYÊN MỤC

jquery file upload (hayageek plugin) error case with json from php

Jquery file upload (hayageek plugin) error case with json from php

28/04/2021
search/filter table rows based on input

Search/filter table rows based on input

28/04/2021
jquery form validation before ajax submit

Jquery form validation before ajax submit

18/03/2021
jquery multiple select dropdown

Jquery multiple select dropdown

28/04/2021
jquery form validation before ajax submit, easy form validation with jquery

Jquery form validation before ajax submit, easy form validation with jquery

25/05/2022
top 17 jquery foreach json array hay nhất 2022

Top 17 jquery foreach json array hay nhất 2022

24/05/2022
how to upload files asynchronously using jquery?

How to upload files asynchronously using jquery?

23/05/2022

22/05/2022

Newsletter

The most important automotive news and events of the day

We won't spam you. Pinky swear.

Chuyên Mục

  • Hỏi Đáp
  • Kiến Thức
  • Sức Khỏe
  • Tử Vi
  • Công Nghệ

News Post

  • Interface php là gì

About

Chúng tôi tạo ra trang web nhằm mục đích mang lại kiến thức bổ ích cho cộng đồng, các bài viết được sưu tầm từ nhiều nguồn trên internet giúp mang lại kiến thức khách quan dành cho bạn

©2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng

Liên Hệ - Giới Thiệu - Nội Quy - Bảo Mật

No Result
View All Result
  • Trang chủ
  • Chuyên mục
    • Hỏi Đáp
    • Kiến Thức
    • Sức Khỏe
    • Tử Vi
    • Công Nghệ
  • Lưu trữ
  • Liên hệ

© 2022 darkedeneurope.com - Website WordPress vì mục đích cộng đồng.