lundi 13 juin 2016

jQuery if var is empty hide button

Currently trying to teach myself javascript/jQuery and just having a little bit of trouble at the moment i've created a internal logo repo to allow easy access to all of the logo the company requires just as a little task.

However i have a separate JSON file with all of the logo details for each set of logos' and then my problem is this:

  var logoType_ai = (value.logo_ai == null) ? value.logo_ai : $(".btn-ai").hide();

I'm trying to get it to check in the json file if the logo.ai variable is empty "" if so then hide the button else display button.

at the moment its just hiding all of the buttons on each set of logos how would i go about making this check each variable group then deciding if it should show or hide the button for that group?

{
  "id": "VMLM",
  "title": "Virgin Money London Marathon",
  "logo_small": "small",
  "logo_medium": "medium",
  "logo_large": "large",
  "swatch_1": "#ed363f",
  "swatch_2": "#0c4493",
  "logo_ai": "",
  "logo_eps": "",
  "logo_svg": "",
  "logo_png": ".png",
  "logo_jpg": ".jpg"
},

Aucun commentaire:

Enregistrer un commentaire