Solved

JQuery Span Write

Posted on 2014-07-25
8
239 Views
Last Modified: 2014-07-25
I need a zero written into empty spans if they are empty, else no change required.

Example:

<span id="empty1"></span> // change to <span id="empty1">0</span>

<span id="empty2">1</span> // no change required

Example fiddle:

http://jsfiddle.net/RichardMorris/D5XJ6/
0
Comment
Question by:Richard Morris
  • 5
  • 3
8 Comments
 
LVL 13

Expert Comment

by:duncanb7
ID: 40220938
$('#empty1,#empty2:empty').text("0");

Try this

Duncan
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40220944
Ignore my previous post

Try this,

$('(#empty1,#empty2):empty').text("0");

it should work
Please read the :empty selector at jquery site
http://api.jquery.com/empty-selector/

Duncan
0
 

Author Comment

by:Richard Morris
ID: 40220975
Hello Duncan,

Doesn't work in my template but this does:

$('#empty1:empty,#empty2:empty').text("0");

Let me know if this will be okay?
0
 
LVL 13

Expert Comment

by:duncanb7
ID: 40220977
it works for  me at my side,
$('(#empty1,#empty2):empty').text("0");
 it might depend on version of jquery

Duncan
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 13

Expert Comment

by:duncanb7
ID: 40220978
Both also works I tested at my server

Duncan
0
 

Author Comment

by:Richard Morris
ID: 40220985
1.10.2 is what's on the server and I can't change it to older.

So what works best for 1.10.2 requirements?
0
 
LVL 13

Accepted Solution

by:
duncanb7 earned 500 total points
ID: 40220987
I am using older one.

Done

Duncan
0
 

Author Closing Comment

by:Richard Morris
ID: 40220997
Great work Duncan!

Here is the reference fiddle:

http://jsfiddle.net/RichardMorris/D5XJ6/1/
0

Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now