自动为alt标记

时间:2016-08-29 08:10:54

标签: javascript jquery

在此脚本中,如何添加alt标记,其值与" NikeAir 32"相同。在这个例子中?

<script> 
  function test_options_rendered(){
    $('.test_option_value').each(function(){            
      if( !$(this).parent().hasClass("conditional")){
        $(this).find('input:radio').first().prop("checked", true);
        // $(".test_radio_option :input:first").prop("checked", true);
      }
    });
    $('.test_radio_option:contains("Nike Air32")').append('<img class="option_img" src="https://image.png">');
  }
 </script>

1 个答案:

答案 0 :(得分:0)

如果您要做的只是向library(shiny) #source("travelcbr1.R") shinyServer(function(input, output) { View <- eventReactive(input$Update, { Accomodation <- switch(input$Accomodation, "Holiday Flat" = 6, "Five Stars" = 5, "Four Stars" = 4, "Three Stars" = 3, "Two Stars" = 2, "One Star" = 1) Price <- input$Price Transportation <- switch(input$Transportation, "Plane" = 4, "Train" = 3, "Coach" = 2, "Car" = 1) HolidayType <- switch(input$HolidayType, "Active" = 8, "Skiing" = 7, "Bathing" = 6, "Wandering" = 5, "Recreation" = 4, "City" = 3, "Language"= 2, "Education" = 1) Season <- switch(input$Season, "December" = 1, "January" = 1, "February" = 1, "March" = 2, "April" = 2, "May" = 2, "June" = 3, "July" = 3, "August" = 3, "September" = 4, "October" = 4, "November" = 4) Duration <- switch(input$Duration, "less than 4" = 1, "4 - 6" = 2, "7 - 9" = 3, "10 - 12" = 4, "13 - 15" = 5, "16 - 20" = 6, "more than 20" = 7) NumberOfPersons <- switch(input$NumberOfPersons, "12" = 12, "11" = 11, "10" = 10, "9" = 9, "8" = 8, "7" = 7, "6" = 6, "5" = 5, "4" = 4, "3" = 3, "2" = 2, "1" = 1) list(Accomodation = Accomodation, NumberOfPersons = NumberOfPersons, Transportation = Transportation, HolidayType = HolidayType, Season = Season, Duration = Duration, Price = Price) }, ignoreNULL = FALSE) output$view <- renderPrint(View()) }) 添加alt标记,您可以这样做:

img

如果你想更动态地做到这一点,你可以这样做:

$('.test_radio_option:contains("Nike Air32")')
   .append('<img class="option_img" alt="Nike Air32" src="https://image.png">')