function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion

Jquery is not working when we activate the Locker Service in the org in custom lightning component

Jquery is not working when we activate the Locker Service in the org. If I try to deactivate my code works fine.
Is there any workaround to include jquery when locker service is enabled.
Requirement: I have a custom lightning component and we are displaying list of records based on custom query.
Now need to download the same records in csv. 
Solution Approach: Trying to provide a button and include jquery.js in component and use jquery functions to read html from component and then download from controller.
Any help will be appreciated.
Below is my code.


<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes" access="global" >
    <ltng:require scripts='/resource/jqueryltng' afterScriptsLoaded="{!c.afterScriptsLoaded}"/>
    <label class="slds-form-element__label" for="org">Click on Download Button to Download CSV</label>
    <ui:button aura:id="button" class="slds-button slds-button--brand" press="{!c.getCsv1}">Download CSV</ui:button>
    <div class="slds-grid" aura:id="displayData" id="dataTable">
        <table class="slds-table slds-table--bordered slds-table--cell-buffer">
                <tr class="slds-text-title--caps">
                    <th class="slds-truncate">First Name</th>
                    <th class="slds-truncate">Last Name</th>
                    <th class="slds-truncate">Company</th>
                <tr class="slds-truncate">
                    <td class="slds-truncate">AAAAA</td>
                    <td class="slds-truncate">YYYYY</td>
                    <td class="slds-truncate">CCCCC</td>


    getCsv : function(component, event, helper) {
            var $rows = $('#dataTable>table').find('tr:has(td)'),
            // Temporary delimiter characters unlikely to be typed by keyboard
            // This is to avoid accidentally splitting the actual contents
            tmpColDelim = String.fromCharCode(11), // vertical tab character
            tmpRowDelim = String.fromCharCode(0), // null character

            // actual delimiter characters for CSV format
            colDelim = '","',
            rowDelim = '"\r\n"',
            // Grab text from table into CSV formatted string
            csv = '"' + $ (i, row) {
                var $row = $(row),
                    $cols = $row.find('td');

                return $ (j, col) {
                    var $col = $(col),
                        text = $col.text();
                    return text;
                    //return text.replace(/"/g, '""'); // escape double quotes

                .split(tmpColDelim).join(colDelim) + '"',

        // Data URI
        csvData = 'data:application/csv;charset=utf-8,' + encodeURIComponent(csv);
        window.location.href = 'data:text/csv;charset=UTF-8,'+ encodeURIComponent(csv);
            'download': 'filename.csv',
                'href': csv,
                'target': '_blank'
    afterScriptsLoaded : function(component, event, helper) {
Peter FribergPeter Friberg
Can't you use the data directly from the controller returning data in JSON format? Why do you need to go through rendered html?
In locker service you only have access to your own part of the DOM. Try to get rid of JQuery and use raw data from controller and the render the HTML as needed from the raw data instead.