jquery - Apply conditional statements within string output in JavaScript -


I am using an XML plugin whose name is "" to parse XML file:

  $ ('# content'). JParse ({ajaxOpts: {url: 'data.xml'}, elementTag: ['title', 'description'], output: '& lt; h2 & gt; jpet0 & lt; / h2 & gt; & lt; p & Gt; jpet1 & lt; / p & gt; '});  

As you can see, the "Jap" variable is correlated with the elementTag array.

How do I see if the jeepet contains data

  $ ('# content'))  

This does not work:

JP ({ajaxOpts: {url: 'data.xml'}, elementTag: ['title', 'description', 'extra'], output: if (jpet0) {'& lt; h2 & gt; ; Jpet0 '} +' & lt; p & gt; jpet1 & lt; / p & gt; & lt; / p & gt;

If I understand the docs properly, then it should work:

  $ ('# content'). JParse ({ajaxOpts: {Url: 'data.xml'}, elementTag: [{elem: 'title', format: function (title) {if (title! = '') Return '& lt; h2 & gt; + Title + '& lt; / h2 & gt;'; else return ''}}}, 'description'], output: 'jpet0 & lt; p & gt; jpet1 & lt; / p & gt;'}) ;  

Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

php - Multiple Select with Explode: only returns the word "Array" -

php - jQuery AJAX Post not working -