Select a SharePoint WebPart Item with jQuery

Kode i .ascx file:

<asp:Label ID="lblSomeLabel" runat="server"></asp:Label>

Kode i endelig html:

<span id="ctl00_m_g_6fb87798_677a_4b2e_804d_6cb23c3672d1_ctl00_lblSomeLabel"></span>

Så hvordan fanger man elementet fra JavaScript?

<script>
  "use strict";
  var $lblSomeLabel = $("[id$='_lblSomeLabel']");
  $lblSomeLabel.hide();
</script>

Læs mere på api.jquery.com:

Attribute Ends With Selector [name$=”value”]

Skriv et svar

Din e-mailadresse vil ikke blive publiceret. Krævede felter er markeret med *

This site uses Akismet to reduce spam. Learn how your comment data is processed.